travis-api/lib/travis/api/v3/result.rb
2015-01-20 16:33:11 +01:00

29 lines
590 B
Ruby

module Travis::API::V3
class Result
attr_accessor :type, :resource
def initialize(type, resource = [])
@type, @resource = type, resource
end
def respond_to_missing?(method, *)
super or method.to_sym == type.to_sym
end
def <<(value)
resource << value
self
end
def render
Renderer[type].render(resource)
end
def method_missing(method, *args)
return super unless method.to_sym == type.to_sym
raise ArgumentError, 'wrong number of arguments (1 for 0)'.freeze if args.any?
resource
end
end
end