Class: ApiSchema::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/api_schema/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, model) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
# File 'lib/api_schema/response.rb', line 6

def initialize(code, model)
  @code = code
  @model = model
  @fields = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(type, *args, &block) ⇒ Object



12
13
14
15
# File 'lib/api_schema/response.rb', line 12

def method_missing(type, *args, &block)
  options = args[1] || {}
  @fields << Field.new(type, args[0], options)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/api_schema/response.rb', line 4

def code
  @code
end

#fieldsObject (readonly)

Returns the value of attribute fields.



4
5
6
# File 'lib/api_schema/response.rb', line 4

def fields
  @fields
end

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/api_schema/response.rb', line 4

def model
  @model
end