Sha256: e350de7fe47786f0ec50d9e2345ea6eaa33c5f4669a83c22db1cef34769faaf7

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

module Onfire
  # An Event is born in #fire and is passed up the ancestor chain of the triggering datastructure.
  # It carries a <tt>type</tt>, the fireing widget <tt>source</tt> and arbitrary payload <tt>data</tt>.
  class Event

    attr_accessor :type, :source, :data

    def initialize(type=nil, source=nil, data=nil)
      @type       = type
      @source     = source
      @data       = data
    end

    def stopped?
      @stopped ||= false
    end

    # Stop event bubbling.
    def stop!
      @stopped = true
    end

    ### FIXME: what about serialization? should we simply forget the source?
    def _dump(depth)
      ""
    end
    def self._load(str)
      ::Onfire::Event.new
    end

    def to_s
      "#<Onfire::Event:0x#{object_id.to_s(16)} type: #{type} source:#{source} data: #{data}>"
    end ; alias :to_s :inspect
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nilclass-onfire-0.1.3.nc lib/onfire/event.rb
nilclass-onfire-0.1.2.nc lib/onfire/event.rb