lib/sequel/plugins/devise.rb in sequel-devise-0.0.3 vs lib/sequel/plugins/devise.rb in sequel-devise-0.0.4

- old
+ new

@@ -10,9 +10,46 @@ module InstanceMethods def changed? # For rememberable !changed_columns.empty? end + + def email_changed? # For validatable + column_changed? :email + end + + def email_was # For confirmable + column_changes[:email].first + end + + # for database_authenticatable: + def assign_attributes(hash) + set hash + end + + def update_attributes(hash, *ignored) + update hash + end + end + + module ClassMethods + Model::HOOKS.each do |hook| + define_method(hook) do |method = nil, options = {}, &block| + if Symbol === (if_method = options[:if]) + orig_block = block + block = nil + method_without_if = method + method = :"_sequel_hook_with_if_#{method}" + define_method(method) do + return unless send if_method + send method_without_if + instance_eval &orig_block if orig_block + end + private method + end + super method, &block + end + end end end end end