Class: Gmaps4rails::ModelHandler
- Inherits:
-
Object
- Object
- Gmaps4rails::ModelHandler
- Defined in:
- lib/gmaps4rails/model_handler.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(object, gmaps4rails_options) ⇒ ModelHandler
constructor
A new instance of ModelHandler.
-
#retrieve_coordinates ⇒ Object
saves coordinates according to the various options.
Constructor Details
#initialize(object, gmaps4rails_options) ⇒ ModelHandler
Returns a new instance of ModelHandler.
11 12 13 14 |
# File 'lib/gmaps4rails/model_handler.rb', line 11 def initialize(object, ) @options = ::OpenStruct.new() @object = object end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
5 6 7 |
# File 'lib/gmaps4rails/model_handler.rb', line 5 def object @object end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/gmaps4rails/model_handler.rb', line 5 def @options end |
Instance Method Details
#retrieve_coordinates ⇒ Object
saves coordinates according to the various options
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gmaps4rails/model_handler.rb', line 17 def retrieve_coordinates return if prevent_geocoding? checked_coordinates do position? ? set_position : set_lat_lng # save normalized address if required object.send("#{normalized_address}=", coordinates.first[:matched_address]) if normalized_address # Call the callback method to let the user do what he wants with the data object.send callback, coordinates.first[:full_data] if callback # update checker if required object.send("#{checker}=", true) if check_geocoding? end end |