Sha256: 5719c48668e3f48e2073d64b51d529145936396fecd8c87b29a273a8c309efc7
Contents?: true
Size: 445 Bytes
Versions: 1
Compression:
Stored size: 445 Bytes
Contents
module MicroEvent VERSION = "1.0.0".freeze def bind(event, &fn) @_ ||= Hash.new{ |h,k| h[k] = [] } fn ? @_[event] << fn : raise(ArgumentError, "no block given") end def unbind(event, &fn) @_ ||= Hash.new{ |h,k| h[k] = [] } fn ? @_[event].delete(fn) : @_.delete(event) || [] end def trigger(event, *args) @_ ||= Hash.new{ |h,k| h[k] = [] } !@_[event].each{ |fn| instance_exec(*args, &fn) }.empty? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
microevent-1.0.0 | lib/microevent.rb |