Module: Mongoid::Publishable::Callbacks::ClassMethods
- Defined in:
- lib/mongoid/publishable/callbacks.rb
Instance Method Summary collapse
-
#add_after_publish_callback(callback) ⇒ Object
add the callback to the collection.
-
#after_publish(*args, &block) ⇒ Object
adds a callback to the list.
-
#after_publish_callbacks ⇒ Object
returns the list of callbacks.
-
#after_publish_callbacks=(values) ⇒ Object
setter for the callbacks.
-
#inherited(subclass) ⇒ Object
pass the callbacks down to the sub-class.
Instance Method Details
#add_after_publish_callback(callback) ⇒ Object
add the callback to the collection
29 30 31 32 33 34 35 36 |
# File 'lib/mongoid/publishable/callbacks.rb', line 29 def add_after_publish_callback(callback) # add it to this object's collection after_publish_callbacks << callback # add it to the subclasses collections too subclasses.each do |subclass| subclass.add_after_publish_callback(callback) end end |
#after_publish(*args, &block) ⇒ Object
adds a callback to the list
39 40 41 42 43 |
# File 'lib/mongoid/publishable/callbacks.rb', line 39 def after_publish(*args, &block) Callback.new(*args, &block).tap do |callback| add_after_publish_callback(callback) end end |
#after_publish_callbacks ⇒ Object
returns the list of callbacks
24 25 26 |
# File 'lib/mongoid/publishable/callbacks.rb', line 24 def after_publish_callbacks @after_publish_callbacks ||= CallbackCollection.new end |
#after_publish_callbacks=(values) ⇒ Object
setter for the callbacks
19 20 21 |
# File 'lib/mongoid/publishable/callbacks.rb', line 19 def after_publish_callbacks=(values) @after_publish_callbacks = CallbackCollection.new(values) end |
#inherited(subclass) ⇒ Object
pass the callbacks down to the sub-class
46 47 48 49 |
# File 'lib/mongoid/publishable/callbacks.rb', line 46 def inherited(subclass) subclass.after_publish_callbacks = after_publish_callbacks super end |