Module: Devise::Orm::MongoMapper::Compatibility::ClassMethods
- Defined in:
- lib/devise/orm/mongo_mapper/compatibility.rb
Instance Method Summary collapse
- #after_create(*args) ⇒ Object
-
#before_create(*args) ⇒ Object
Hooks for confirmable.
- #before_save(*args) ⇒ Object
-
#find(*args) ⇒ Object
Add ActiveRecord like finder.
- #wrap_hook(action, method, *args) ⇒ Object
Instance Method Details
#after_create(*args) ⇒ Object
30 31 32 |
# File 'lib/devise/orm/mongo_mapper/compatibility.rb', line 30 def after_create(*args) wrap_hook(:after, :create, *args) end |
#before_create(*args) ⇒ Object
Hooks for confirmable
26 27 28 |
# File 'lib/devise/orm/mongo_mapper/compatibility.rb', line 26 def before_create(*args) wrap_hook(:before, :create, *args) end |
#before_save(*args) ⇒ Object
34 35 36 |
# File 'lib/devise/orm/mongo_mapper/compatibility.rb', line 34 def before_save(*args) wrap_hook(:before, :save, *args) end |
#find(*args) ⇒ Object
Add ActiveRecord like finder
53 54 55 56 57 58 59 60 |
# File 'lib/devise/orm/mongo_mapper/compatibility.rb', line 53 def find(*args) case args.first when :first, :all send(args.shift, *args) else where(:'_id' => args.first).first end end |
#wrap_hook(action, method, *args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/devise/orm/mongo_mapper/compatibility.rb', line 38 def wrap_hook(action, method, *args) = args. args.each do |callback| callback_method = :"#{callback}_callback_wrap" send action, method, callback_method class_eval <<-METHOD, __FILE__, __LINE__ + 1 def #{callback_method} #{callback} if #{[:if] || true} end METHOD end end |