Module: Plate::Callbacks::InstanceMethods
- Defined in:
- lib/plate/callbacks.rb
Instance Method Summary collapse
Instance Method Details
#around_callback(name, &block) ⇒ Object
36 37 38 39 40 |
# File 'lib/plate/callbacks.rb', line 36 def around_callback(name, &block) run_callback "before_#{name}".to_sym block.call run_callback "after_#{name}".to_sym end |
#run_callback(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/plate/callbacks.rb', line 42 def run_callback(name) if callbacks = self.class.callbacks[name] callbacks.each do |callback| if Proc === callback callback.call(self) elsif self.respond_to?(callback) self.send(callback) end end end end |