Sha256: 8997255a020653f5711efe8870f982034e3d7d5d85df34420359c3ab2aba9503

Contents?: true

Size: 599 Bytes

Versions: 15

Compression:

Stored size: 599 Bytes

Contents

require 'ostruct'

module AASM
  class StateMachine
    def self.[](*args)
      (@machines ||= {})[args]
    end

    def self.[]=(*args)
      val = args.pop
      (@machines ||= {})[args] = val
    end
    
    attr_accessor :states, :events, :initial_state, :config
    attr_reader :name
    
    def initialize(name)
      @name   = name
      @initial_state = nil
      @states = []
      @events = {}
      @config = OpenStruct.new
    end

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

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
caleb-aasm-2.0.0 lib/state_machine.rb
caleb-aasm-2.0.1 lib/state_machine.rb
caleb-aasm-2.0.2 lib/state_machine.rb
eric-aasm-2.0.2 lib/state_machine.rb
eric-aasm-2.0.3 lib/state_machine.rb
gvaughn-aasm-2.0.4 lib/state_machine.rb
rubyist-aasm-2.0.1 lib/state_machine.rb
rubyist-aasm-2.0.2 lib/state_machine.rb
runcoderun-aasm-2.0.2.1 lib/state_machine.rb
runcoderun-aasm-2.0.2.2 lib/state_machine.rb
runcoderun-aasm-2.0.2.3 lib/state_machine.rb
runcoderun-aasm-2.0.2.4 lib/state_machine.rb
snoozer05-aasm-2.0.2 lib/state_machine.rb
aasm-2.0.1 lib/state_machine.rb
aasm-2.0.2 lib/state_machine.rb