Sha256: fdabb80adf0d2281aa75565b9526e6c3a8b4ff91e43add5515f0f5c17d00b864
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
module Gumdrop::Support module Callbacks # For defining callbacks def callback(*callback_names) callback_names.each do |name| class_eval <<-EOF def #{name}(*args, &block) if block @_#{name} = [] if @_#{name}.nil? @_#{name} << block elsif @_#{name} and !@_#{name}.nil? @_#{name}.each do |cb| cb.call(*args) end end end def clear_#{name}() @_#{name} = nil end EOF end end alias_method :callbacks, :callback alias_method :define_callback, :callback alias_method :define_callbacks, :callback end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gumdrop-0.8.0 | lib/gumdrop/support/callbacks.rb |