Sha256: a1728d4ac1504f94d398c0a506774aa010a3c77e2d9244eecd6f6d839ef8771a

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

module NinjaModel
  class Railtie < Rails::Railtie

    config.ninja_model = ActiveSupport::OrderedOptions.new

    config.app_middleware.insert_after "::ActionDispatch::Callbacks",
      "NinjaModel::Adapters::AdapterManagement"

    initializer 'ninja_model.logger' do |app|
      NinjaModel::set_logger(Rails.logger)
    end

    initializer 'ninja_model_extend_active_record' do |app|
      ActiveSupport.on_load(:active_record) do
        require 'ninja_model/rails_ext/active_record'
      end
    end

    initializer 'ninja_model_load_specs' do |app|
      config_path = File.join(app.paths.config.to_a.first, "ninja_model.yml")
      if File.exists?(config_path)
        require 'erb'
        require 'yaml'
        app.config.ninja_model.specs = YAML::load(ERB.new(IO.read(config_path)).result)
      else
        NinjaModel.logger.warn "[ninja-model] *WARNING* Unable to find configuration file at #{config_path}"
      end
    end

    config.after_initialize do |app|
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ninja-model-0.5.2 lib/ninja_model/railtie.rb
ninja-model-0.5.1 lib/ninja_model/railtie.rb