Class: Sourcescrub::Models::CompanyItems
- Defined in:
- lib/sourcescrub/models/concerns/company_items.rb
Overview
Tag
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#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
-
#parse_response_items(identifier, kclass_name, response) ⇒ Object
the identifier can be domain or SS ID.
Methods inherited from Entity
#as_json, #fields, #parse_response
Methods included from Utils::Response
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/company_items.rb', line 8 def identifier @identifier end |
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/company_items.rb', line 8 def items @items end |
#total ⇒ Object
Returns the value of attribute total.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/company_items.rb', line 8 def total @total end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/sourcescrub/models/concerns/company_items.rb', line 8 def type @type end |
Instance Method Details
#parse_response_items(identifier, kclass_name, response) ⇒ Object
the identifier can be domain or SS ID
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sourcescrub/models/concerns/company_items.rb', line 11 def parse_response_items(identifier, 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, 'identifier', identifier) dynamic_define_method(self, 'type', kclass_name) dynamic_define_method(self, 'total', response.dig(total_key) || 0) dynamic_define_method(self, 'items', company_items(kclass_name, response.dig(items_key) || [])) self end |