Class: GoogleGeocodeApi::Object
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- GoogleGeocodeApi::Object
- Defined in:
- lib/google_geocode_api/object.rb
Overview
OpenStruct object for Google Geocode API
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Object
constructor
rubocop:disable Style/OpenStructUse.
- #to_ostruct(obj) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Object
rubocop:disable Style/OpenStructUse
8 9 10 |
# File 'lib/google_geocode_api/object.rb', line 8 def initialize(attributes) super to_ostruct(attributes) end |
Instance Method Details
#to_ostruct(obj) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/google_geocode_api/object.rb', line 12 def to_ostruct(obj) if obj.is_a?(Hash) # rubocop:disable Style/CaseLikeIf OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h) # rubocop:disable Style/HashTransformValues, Style/OpenStructUse, Style/MapToHash elsif obj.is_a?(Array) obj.map { |o| to_ostruct(o) } else # Assumed to be a primitive value obj end end |