Class: Apipony::Response
- Inherits:
-
Object
- Object
- Apipony::Response
- Defined in:
- lib/apipony/response.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#example(&block) ⇒ Object
Returns the value of attribute example.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #attribute(name, **params, &block) ⇒ Object
-
#initialize(status, array: false, &block) ⇒ Response
constructor
A new instance of Response.
- #is_array? ⇒ Boolean
Constructor Details
#initialize(status, array: false, &block) ⇒ Response
Returns a new instance of Response.
3 4 5 6 7 8 |
# File 'lib/apipony/response.rb', line 3 def initialize(status, array: false, &block) @status = status @attributes = [] @array = array instance_eval(&block) if block_given? end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
2 3 4 |
# File 'lib/apipony/response.rb', line 2 def attributes @attributes end |
#example(&block) ⇒ Object
Returns the value of attribute example.
2 3 4 |
# File 'lib/apipony/response.rb', line 2 def example @example end |
#status ⇒ Object
Returns the value of attribute status.
2 3 4 |
# File 'lib/apipony/response.rb', line 2 def status @status end |
Instance Method Details
#attribute(name, **params, &block) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/apipony/response.rb', line 22 def attribute(name, **params, &block) if params[:example] @use_attribute_examples = true end @attributes << Apipony::ResponseAttribute.new(name, **params, &block) end |
#is_array? ⇒ Boolean
10 11 12 |
# File 'lib/apipony/response.rb', line 10 def is_array? !! @array end |