Module: Restio::Util::Callback
- Included in:
- Connector::Generic
- Defined in:
- lib/restio/util/callback.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
Instance Method Summary collapse
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
4 5 6 |
# File 'lib/restio/util/callback.rb', line 4 def callbacks @callbacks end |
Instance Method Details
#register_callback(stage, action, method_or_block) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/restio/util/callback.rb', line 5 def register_callback stage, action, method_or_block @callbacks ||= {} @callbacks[action] ||= {} @callbacks[action][stage] ||= [] @callbacks[action][stage] << method_or_block end |
#run_callbacks(stage, action) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/restio/util/callback.rb', line 11 def run_callbacks stage, action get_callbacks(action,stage).each do |cb| if cb.is_a? Symbol case @type when :collection then @klass.send(cb) when :resource then @instance.send(cb) end end end end |