Module: Sourcescrub::Utils::Response
- Included in:
- Models::Entity
- Defined in:
- lib/sourcescrub/utils/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 31 32 33 34 35 36 37 38 | # File 'lib/sourcescrub/utils/response.rb', line 10 def dynamic_attributes(object, attribute_names, response) # Retrieve request limit data from header # # .date # .content_type # .server # .content_length # .request_context # .strict_transport_security # .x_ratelimit_limit # .x_ratelimit_remaining # .x_ratelimit_reset headers = response.dig('headers') headers&.keys&.each do |attr_name| object.class.send(:define_method, attr_name.gsub('-', '_').to_sym) do headers[attr_name] end end # Setup attributes attribute_names.each do |attr_name| attr_value = response.dig(attr_name) attr_value = nil if attr_name == 'currentEmployeeRange' && attr_value.is_a?(Integer) dynamic_define_method(object, attr_name, attr_value) end object end |