Sha256: 88394b8e48aaa27e86349137d4d6917d9fcdb5c9238ab78fe8e6b7b0d46db608

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

require "surrounded/rails/version"
require "surrounded"
require "rails"
module Surrounded
  class Railtie < ::Rails::Railtie
    initializer 'surrounded.active_record' do |app|
      ActiveRecord::Base.class_eval {
        include Surrounded
        # There is no earlier hook to set this variable.
        # The after_initialize callback occurs to late because
        # the initialize method has a procedure which calls
        # respond_to? and Surrounded adds respond_to_missing?
        # to get information from the context (which is the first
        # item in the @__surroundings__ collection).
        def surroundings
          @__surroundings__ ||= []
        end
      }
    end

    initializer 'surrounded.action_controller' do |app|
      ActionController::Base.send(:include, Surrounded)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
surrounded-rails-0.1.2 lib/surrounded/railtie.rb
surrounded-rails-0.1.1 lib/surrounded/railtie.rb