Module: Crunchbase::Utilities::Response
- Included in:
- Models::Entity
- Defined in:
- lib/crunchbase/utilities/response.rb
Overview
Parse the response. build with object
Class Method Summary collapse
Class Method Details
.dynamic_attributes(object, attribute_names, response) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/crunchbase/utilities/response.rb', line 10 def dynamic_attributes(object, attribute_names, response) attribute_names.each do |attribute_name| attribute_value = field_value(attribute_name, response) dynamic_define_method(object, attribute_name, attribute_value) end [attribute_names & special_attributes].flatten.each do |attribute_name| attribute_names.delete(attribute_name) hash_datas = response&.dig(attribute_name) values = hash_datas&.map { |k, v| v if %w[uuid permalink value].include?(k) }&.compact || [] dynamic_define_method(object, attribute_name, values) hash_datas&.keys&.each do |key| next unless %w[uuid permalink].include?(key) dynamic_define_method(object, key, hash_datas&.dig(key)) end end object end |