Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/resugan/object.rb
Instance Method Summary collapse
- #_fire(event, params = {}) ⇒ Object
- #_listener(event, options = {}, &block) ⇒ Object
- #resugan(namespace = '', &block) ⇒ Object
Instance Method Details
#_fire(event, params = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/resugan/object.rb', line 14 def _fire(event, params = {}) params[:_source] = caller[0] if Resugan::Kernel.line_trace_enabled? current_thread = Thread.current if current_thread.resugan_context current_thread.resugan_context.register(event, params) else puts "WARN: #{event} called in #{caller[0]} but was not inside a resugan {} block" if Resugan::Kernal.warn_no_context_events? end end |
#_listener(event, options = {}, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/resugan/object.rb', line 25 def _listener(event, = {}, &block) Resugan::Kernel.register_with_namespace([:namespace], event, [:id], ->(params) { block.call(params) }) end |
#resugan(namespace = '', &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/resugan/object.rb', line 2 def resugan(namespace = '', &block) current_thread = Thread.current current_thread.push_resugan_context(namespace) block.call context = current_thread.pop_resugan_context context.invoke context end |