Sha256: c36f66be6bf521fcc178b0f13afc469d0f215d9b9de859f5aed6b53e089fec76

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'geokit-rails3'
require 'rails'

module Geokit

  class Railtie < Rails::Railtie
    
    config.geokit = ActiveSupport::OrderedOptions.new
    config.geokit.geocoders = ActiveSupport::OrderedOptions.new
    
    initializer 'geokit-rails3.insert_into_active_record' do
      ActiveSupport.on_load :active_record do
        ActiveRecord::Base.send(:include, Geokit::ActsAsMappable::Glue)
        Geokit::Geocoders.logger = ActiveRecord::Base.logger
      end
    end
    
    initializer 'geokit-rails3.insert_into_action_controller' do
      ActiveSupport.on_load :action_controller do
        ActionController::Base.send(:include, Geokit::GeocoderControl)
        ActionController::Base.send(:include, GeoKit::IpGeocodeLookup)
      end
    end
    
    config.after_initialize do |app|
      options = app.config.geokit
      geocoders_options = options.delete(:geocoders)
      
      options.each do |k,v|
        Geokit::send("#{k}=", v)
      end
      geocoders_options.each do |k,v|
        Geokit::Geocoders::send("#{k}=", v)
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geokit-rails3-0.0.4 lib/geokit-rails3/railtie.rb
geokit-rails3-0.0.3 lib/geokit-rails3/railtie.rb