Class: Mongoid::Publishable::Callback
- Inherits:
-
Object
- Object
- Mongoid::Publishable::Callback
- Defined in:
- lib/mongoid/publishable/callback.rb
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Callback
constructor
A new instance of Callback.
- #process(object) ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Callback
Returns a new instance of Callback.
4 5 6 7 8 9 10 11 12 |
# File 'lib/mongoid/publishable/callback.rb', line 4 def initialize(*args, &block) if block_given? @method = block elsif args.length == 1 && args[0].kind_of?(Symbol) @method = args[0] else raise ArgumentError, "after_publish only allows a block or a symbol method reference as arguments" end end |
Instance Method Details
#process(object) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/mongoid/publishable/callback.rb', line 14 def process(object) if @method.respond_to?(:yield) @method.yield(object) else object.send(@method) end end |