Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/tester/definition/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
Instance Method Summary collapse
- #add_field(new_field) ⇒ Object
- #field_display(field) ⇒ Object
-
#initialize(status_code) ⇒ Response
constructor
A new instance of Response.
- #to_s ⇒ Object
Constructor Details
#initialize(status_code) ⇒ Response
5 6 7 8 |
# File 'lib/tester/definition/response.rb', line 5 def initialize(status_code) self.code = status_code self.body = [] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/tester/definition/response.rb', line 3 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
2 3 4 |
# File 'lib/tester/definition/response.rb', line 2 def code @code end |
Instance Method Details
#add_field(new_field) ⇒ Object
10 11 12 13 |
# File 'lib/tester/definition/response.rb', line 10 def add_field(new_field) self.body << new_field self end |
#field_display(field) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tester/definition/response.rb', line 23 def field_display field des = field.display_class if field.has_subfields? des = {} s = field.fields.map do |f| des[f.name] = field_display f end des.to_json end des end |
#to_s ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/tester/definition/response.rb', line 15 def to_s des = {} s = self.body.map do |f| des[f.name] = field_display f end des.to_json end |