Module: SimpleMapper::CallbacksExtension
- Included in:
- HttpAdapter
- Defined in:
- lib/simple_mapper/default_plugins/callbacks.rb
Instance Method Summary collapse
Instance Method Details
#add_callback(name, &block) ⇒ Object
6 7 8 |
# File 'lib/simple_mapper/default_plugins/callbacks.rb', line 6 def add_callback(name,&block) callbacks[name] << block end |
#callbacks ⇒ Object
3 4 5 |
# File 'lib/simple_mapper/default_plugins/callbacks.rb', line 3 def callbacks @callbacks ||= Hash.new {|h,k| h[k] = []} end |
#run_callback(name, *args) ⇒ Object
9 10 11 12 |
# File 'lib/simple_mapper/default_plugins/callbacks.rb', line 9 def run_callback(name, *args) args = args.first if args.length == 1 callbacks[name].inject(args) {|args,cb| cb.call(*args) || args} end |