Sha256: 4d1db6e3d7818cd7730f8e8147b7d8b470dc738887407997163b0bab27e6cff8

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

require "surrounded/rails/version"
require "surrounded"
require "rails"
module Surrounded
  class Railtie < ::Rails::Railtie
    initializer 'surrounded.active_record' do |app|
      ActiveRecord::Base.send(:include, ::Surrounded)
      ActiveRecord::Base.class_eval {
        # This relies on a private method (present in Rails 3 and 4)
        # because 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 init_internals_with_surrounded
          Surrounded.create_surroundings(self)
          init_internals_without_surrounded
        end
        alias_method_chain :init_internals, :surrounded
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
surrounded-rails-0.0.2 lib/surrounded/railtie.rb