Module: Authlogic::ActsAsAuthentic::Password::Callbacks

Defined in:
lib/authlogic/acts_as_authentic/password.rb

Overview

Callbacks / hooks to allow other modules to modify the behavior of this module.

Constant Summary collapse

METHODS =
[
  "before_password_set", "after_password_set",
  "before_password_verification", "after_password_verification"
]

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/authlogic/acts_as_authentic/password.rb', line 180

def self.included(klass)
  return if klass.crypted_password_field.nil?
  klass.define_callbacks *METHODS
  
  # If Rails 3, support the new callback syntax
  if klass.send(klass.respond_to?(:singleton_class) ? :singleton_class : :metaclass).method_defined?(:set_callback)
    METHODS.each do |method|
      klass.class_eval <<-"end_eval", __FILE__, __LINE__
        def self.#{method}(*methods, &block)
          set_callback :#{method}, *methods, &block
        end
      end_eval
    end
  end
end