Sha256: cbe91666b77490dcc0f000132234ee2fae3661ad81162829dc85732ec9b2ec15

Contents?: true

Size: 877 Bytes

Versions: 13

Compression:

Stored size: 877 Bytes

Contents

module AASM
  class StateMachine

    # the following two methods provide the storage of all state machines
    def self.[](clazz)
      (@machines ||= {})[clazz.to_s]
    end

    def self.[]=(clazz, machine)
      (@machines ||= {})[clazz.to_s] = machine
    end

    attr_accessor :states, :events, :initial_state, :config
    attr_reader :name

    # QUESTION: what's the name for? [alto, 2012-11-28]
    def initialize(name)
      @name = name
      @initial_state = nil
      @states = []
      @events = {}
      @config = OpenStruct.new
    end

    # called internally by Ruby 1.9 after clone()
    def initialize_copy(orig)
      super
      @states = @states.dup
      @events = @events.dup
    end

    def add_state(name, clazz, options)
      @states << AASM::State.new(name, clazz, options) unless @states.include?(name)
    end

  end # StateMachine
end # AASM

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
aasm-3.2.0 lib/aasm/state_machine.rb
aasm-3.1.1 lib/aasm/state_machine.rb
aasm-3.1.0 lib/aasm/state_machine.rb
aasm-3.0.26 lib/aasm/state_machine.rb
aasm-3.0.25 lib/aasm/state_machine.rb
aasm-3.0.24 lib/aasm/state_machine.rb
aasm-3.0.23 lib/aasm/state_machine.rb
aasm-3.0.22 lib/aasm/state_machine.rb
aasm-3.0.21 lib/aasm/state_machine.rb
aasm-3.0.20 lib/aasm/state_machine.rb
aasm-3.0.19 lib/aasm/state_machine.rb
aasm-3.0.18 lib/aasm/state_machine.rb
aasm-3.0.17 lib/aasm/state_machine.rb