Sha256: 38f6d533805b3a04166d807f213aed991c2ec9d63604a6a95f15d8f24971d745

Contents?: true

Size: 532 Bytes

Versions: 5

Compression:

Stored size: 532 Bytes

Contents

module StateShifter
  class Event
    attr_reader :name, :from, :to, :guards, :callback

    def initialize from, name, to=nil, guards=nil, callback=nil
      @name = name
      @from = from
      @to = to
      @guards = [guards].flatten.compact
      @callback = callback
    end

    def has_guards?
      !@guards.nil?
    end

    def has_callback?
      !@callback.nil?
    end

    def draw(graph, options = {})
      to = @to ? @to : @from
      graph.add_edges(@from.to_s, to.to_s, :label => @name.to_s)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
state_shifter-1.1.3 lib/state_shifter/event.rb
state_shifter-1.1.2 lib/state_shifter/event.rb
state_shifter-1.0.7 lib/state_shifter/event.rb
state_shifter-1.0.5 lib/state_shifter/event.rb
state_shifter-1.0.3 lib/state_shifter/event.rb