Sha256: a8e64b1d8bc528440800e97251f16a7e289d7d9bc5e9e8f83e72158eaa9f84c5
Contents?: true
Size: 445 Bytes
Versions: 1
Compression:
Stored size: 445 Bytes
Contents
module MicroEvent VERSION = "1.0.1".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.1 | lib/microevent.rb |