Module: ActiveLdap::Callbacks

Defined in:
lib/active_ldap/callbacks.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append_features(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_ldap/callbacks.rb', line 5

def self.append_features(base)
  super

  base.class_eval do
    include ActiveRecord::Callbacks

    unless respond_to?(:instantiate_with_callbacks)
      extend ClassMethods
      class << self
        alias_method_chain :instantiate, :callbacks
      end
      alias_method_chain :initialize, :callbacks
    end

    def callback(method)
      super
    rescue ActiveRecord::ActiveRecordError
      raise Error, $!.message
    end
  end
end

Instance Method Details

#initialize_with_callbacks(attributes = nil) ⇒ Object

:nodoc:



43
44
45
46
47
48
49
50
# File 'lib/active_ldap/callbacks.rb', line 43

def initialize_with_callbacks(attributes = nil) #:nodoc:
  initialize_without_callbacks(attributes)
  result = yield self if block_given?
  if respond_to_without_attributes?(:after_initialize)
    callback(:after_initialize)
  end
  result
end