lib/devise/models.rb in devise-1.1.pre2 vs lib/devise/models.rb in devise-1.1.pre3

- old
+ new

@@ -55,26 +55,29 @@ # with specific values for this model. Please check your Devise initializer # for a complete description on those values. # def devise(*modules) raise "You need to give at least one Devise module" if modules.empty? - options = modules.extract_options! + options = modules.extract_options! @devise_modules = Devise::ALL & modules.map(&:to_sym).uniq - Devise.orm_class.included_modules_hook(self) do - devise_modules.each do |m| - include Devise::Models.const_get(m.to_s.classify) - end - + devise_modules_hook! do + devise_modules.each { |m| include Devise::Models.const_get(m.to_s.classify) } options.each { |key, value| send(:"#{key}=", value) } end end # Stores all modules included inside the model, so we are able to verify # which routes are needed. def devise_modules @devise_modules ||= [] + end + + # The hook which is called inside devise. So your ORM can include devise + # compatibility stuff. + def devise_modules_hook! + yield end # Find an initialize a record setting an error if it can't be found. def find_or_initialize_with_error_by(attribute, value, error=:invalid) if value.present?