Sha256: 30d86d24f5204326b6b82b020acccba66df277e5ed9e2d5c977f3db9d9c00c08

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module StateFu
  class Sprocket # Abstract Superclass of State & Event
    include StateFu::Helper # define apply!

    attr_reader :machine, :name, :options, :hooks

    def initialize(machine, name, options={})
      @machine = machine
      @name    = name.to_sym
      @options = options.symbolize_keys!
      @hooks   = StateFu::Hooks.for( self )
    end

    # sneaky way to make some comparisons / duck typing a bit cleaner
    alias_method :to_sym,  :name

    def add_hook slot, name, value
      @hooks[slot.to_sym] << [name.to_sym, value]
    end

    def lathe(options={}, &block)
      StateFu::Lathe.new( machine, self, options, &block )
    end

    def deep_copy
      raise NotImeplementedError # abstract
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
davidlee-state-fu-0.2.0 lib/state_fu/sprocket.rb