Sha256: 43dc4ad5e6a85180279402e5e25da61bdc66f9af5b04ace27ce8b1a3a9c23f15

Contents?: true

Size: 688 Bytes

Versions: 6

Compression:

Stored size: 688 Bytes

Contents

module AASM
  class StateMachine
    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

    def initialize(name)
      @name = name
      @initial_state = nil
      @states = []
      @events = {}
      @config = OpenStruct.new
    end

    def initialize_copy(orig)
      super
      @states = @states.dup
      @events = @events.dup
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aasm-3.0.14 lib/aasm/state_machine.rb
aasm-3.0.13 lib/aasm/state_machine.rb
aasm-3.0.12 lib/aasm/state_machine.rb
aasm-3.0.11 lib/aasm/state_machine.rb
aasm-3.0.10 lib/aasm/state_machine.rb
aasm-3.0.9 lib/aasm/state_machine.rb