Sha256: 173dcbb1948465f72d068c4272cd72467d031100b189d7a532e569d01ee64c2f

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

module MongoModel
  class Railtie < Rails::Railtie
    initializer "mongomodel.logger" do
      MongoModel.logger ||= ::Rails.logger
    end
    
    initializer "mongomodel.rescue_responses" do
      ActionDispatch::ShowExceptions.rescue_responses['MongoModel::DocumentNotFound'] = :not_found
    end
    
    initializer "mongomodel.database_configuration" do |app|
      require 'erb'
      
      config = Pathname.new(app.paths.config.to_a.first).join("mongomodel.yml")
      
      if File.exists?(config)
        mongomodel_configuration = YAML::load(ERB.new(IO.read(config)).result)
        MongoModel.configuration = mongomodel_configuration[Rails.env]
      end
    end
    
    initializer "mongomodel.passenger_forking" do |app|
      if defined?(PhusionPassenger)
        PhusionPassenger.on_event(:starting_worker_process) do |forked|
          MongoModel.database.connection.connect if forked
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongomodel-0.2.8 lib/mongomodel/railtie.rb