Class: Sourcescrub::Models::SourceItems
- Defined in:
- lib/sourcescrub/models/concerns/source_items.rb
Overview
Tag
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#total ⇒ Object
Returns the value of attribute total.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Methods inherited from Entity
#as_json, #fields, #parse_response
Methods included from Utils::Response
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/source_items.rb', line 8 def items @items end |
#total ⇒ Object
Returns the value of attribute total.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/source_items.rb', line 8 def total @total end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/source_items.rb', line 8 def type @type end |
Instance Method Details
#parse_response_items(kclass_name, response) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sourcescrub/models/concerns/source_items.rb', line 10 def parse_response_items(kclass_name, response) headers = response.dig('headers') headers&.keys&.each do |attr_name| self.class.send(:define_method, attr_name.gsub('-', '_').to_sym) do headers[attr_name] end end dynamic_define_method(self, 'type', kclass_name) dynamic_define_method(self, 'total', response.dig('total') || 0) dynamic_define_method(self, 'items', source_items(kclass_name, response.dig('items') || [])) self end |