Module: Gmaps4rails::ActsAsGmappable::ClassMethods

Defined in:
lib/gmaps4rails/acts_as_gmappable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_gmappable(args = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gmaps4rails/acts_as_gmappable.rb', line 20

def acts_as_gmappable args = {}    
  
  validate :process_geocoding
  
  #instance method containing all the options to configure the behaviour of the gem regarding the current Model
  define_method "gmaps4rails_options" do
    {
      :process_geocoding  => args[:process_geocoding].nil? ?  true : args[:process_geocoding],
      :check_process      => args[:check_process].nil?     ?  true : args[:check_process],
      :checker            => args[:checker]                || "gmaps",
                                                           
      :lat_column         => args[:lat]                    || "latitude",
      :lng_column         => args[:lng]                    || "longitude",

      # purposefully no default. 
      # Leaving out the :position arg means we are using the default lat/lng to store coordinates
      :position           => args[:position], 
                                                           
      :msg                => args[:msg]                    || "Address invalid",
      :validation         => args[:validation].nil?        ?   true  : args[:validation],
                                                                                                                           
      :language           => args[:language]               || "en",
      :protocol           => args[:protocol]               || "http",
      
      :address            => args[:address]                || "gmaps4rails_address",
      :callback           => args[:callback],
      :normalized_address => args[:normalized_address]
    }
  end
  
end