Sha256: c362a646a4c881134a7149bc72c3eb36ed691bee59e246141db349ab4c20f9a1

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'canard'
require 'rails'

module Canard
  class Railtie < Rails::Railtie

    initializer "carard.no_eager_loading", :before => 'before_eager_loading' do |app|
      ActiveSupport::Dependencies.autoload_paths.reject!{ |path| Canard.load_paths.include?(path) }
      # Don't eagerload our configs, we'll deal with them ourselves
      app.config.eager_load_paths = app.config.eager_load_paths.reject do |path|
        Canard.load_paths.include?(path)
      end
    end

    initializer "canard.active_record" do |app|
      ActiveSupport.on_load :active_record do
        Canard::Abilities.default_path = File.expand_path('app/abilities', Rails.root)
        extend Canard::UserModel
        Canard.find_abilities
      end
    end

    initializer "canard.abilities_reloading", :after => "action_dispatch.configure" do |app|
      if ActionDispatch::Reloader.respond_to?(:to_prepare)
        ActionDispatch::Reloader.to_prepare { Canard.find_abilities }
      else
        ActionDispatch::Reloader.before { Canard.find_abilities }
      end
    end

    rake_tasks do
      load File.expand_path('../../tasks/canard.rake', __FILE__)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
canard-0.4.0.pre lib/canard/railtie.rb