module CitrusAdmin::Utils::EventEmitter
Public Instance Methods
emit(*args)
click to toggle source
Emit event
# File lib/citrus-admin/util/utils.rb, line 52 def emit *args event = args.shift if @once_blocks && block = @once_blocks[event] @once_blocks.delete event elsif !@on_blocks || !block = @on_blocks[event] return end block.call *args end
on(event, &block)
click to toggle source
Register event
@param [String] event
# File lib/citrus-admin/util/utils.rb, line 38 def on event, &block @on_blocks ||= {} @on_blocks[event] = block end
once(event, &block)
click to toggle source
Register event once
@param [String] event
# File lib/citrus-admin/util/utils.rb, line 46 def once event, &block @once_blocks ||= {} @once_blocks[event] = block end