Sha256: b2acd9c862c07f5307b446c4c724d0ab0f5c8a15b0a60d3ebed0b44af150b258

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

module MicroSessions
  class Railtie < Rails::Railtie
    initializer "micro_sessions.insert" do
      ActiveSupport.on_load(:action_controller) do
        MicroSessions::Railtie.insert_controller
      end

      ActiveSupport.on_load(:action_view) do
        MicroSessions::Railtie.insert_view
      end
    end

    def self.insert_controller
      ActionController::Base.send(:include, MicroSessions::Controller)
      ActionController::Base.send(:include, MicroSessions::Helpers::UrlHelper)
    end

    def self.insert_view
      ActionView::Helpers::FormTagHelper.send(:include, MicroSessions::Helpers::FormTagHelper)
      ActionView::Helpers::UrlHelper.send(:include, MicroSessions::Helpers::UrlHelper)
    end

    MicroSessions::Railtie.insert_controller
    MicroSessions::Railtie.insert_view

    config.after_initialize do
      MicroSessions::Railtie.insert_controller
      MicroSessions::Railtie.insert_view
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micro_sessions-0.2.0 lib/micro_sessions/railtie.rb