Sha256: e139090804a2a97b29431ef4e271c96710232d889e0c4c56defc2a12bd2cac52

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module Light
  module Decorator
    class Railtie < Rails::Railtie
      config.after_initialize do |app|
        app.config.paths.add 'app/decorators', eager_load: true
      end

      initializer 'light.decorator.inject_orm' do
        ActiveSupport.on_load :active_record do
          ActiveRecord::Base.send(:include, ::Light::Decorator::Concerns::Base)
          ActiveRecord::Relation.send(:include, ::Light::Decorator::Concerns::Relation)
          ActiveRecord::Associations::CollectionProxy.send(
            :include, ::Light::Decorator::Concerns::Associations::CollectionProxy
          )
        end
      end

      initializer 'light.decorator.load_view_context' do
        [:action_controller, :action_mailer].each do |action_module|
          ActiveSupport.on_load action_module do
            include ::Light::Decorator::ViewContext
          end
        end
      end

      generators do |app|
        Rails::Generators.configure! app.config.generators
        Rails::Generators.hidden_namespaces.uniq!

        require 'generators/rails/hooks'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
light-decorator-1.0.1 lib/light/decorator/railtie.rb
light-decorator-1.0.0 lib/light/decorator/railtie.rb