Sha256: c24a540fdb70f9dc4482ea2ebbdbce0ba86bff515d1fd8e515df99747b044acd

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 Bytes

Contents

require "rails/railtie"

module SimpleHelpers
  class Railtie < Rails::Railtie

    generators do
      require "simple_helpers/generators"
    end

    initializer "simple_helpers.initialize" do
      ::ActionController::Base.instance_eval do
        include SimpleHelpers::ActionController

        initialize_method = instance_method(:initialize)

        define_method :initialize do |*args|
          if SimpleHelpers::Config.allowed_controller?(self.class.name)
            simple_helper(SimpleHelpers::Config.helpers)
          else
            SimpleHelpers::Support.log "Controller #{self.class.inspect} not allowed."
          end

          initialize_method.bind(self).call(*args)
        end
      end
      ::I18n.load_path += Dir[File.dirname(__FILE__) + "/../../locales/*.yml"]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_helpers-1.0.0 lib/simple_helpers/railtie.rb
simple_helpers-0.0.5 lib/simple_helpers/railtie.rb
simple_helpers-0.0.4 lib/simple_helpers/railtie.rb
simple_helpers-0.0.3 lib/simple_helpers/railtie.rb
simple_helpers-0.0.2 lib/simple_helpers/railtie.rb