Sha256: e877db0a69e0298dd7718cd37f3888c192c83cf3f66cce7cbaff6214ed481b99

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 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

1 entries across 1 versions & 1 rubygems

Version Path
simple_helpers-0.0.1 lib/simple_helpers/railtie.rb