Sha256: ada1e17a6e21dec8a82b70d57f13521a5fb3c3ebfcc51d63984321b1867b6b8b

Contents?: true

Size: 639 Bytes

Versions: 5

Compression:

Stored size: 639 Bytes

Contents

class AASM::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 clone
    klone = super
    klone.states = states.clone
    klone.events = events.clone
    klone
  end

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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
aasm-2.4.0 lib/aasm/state_machine.rb
alexrevin-aasm_numerical-2.3.1 lib/alexrevin-aasm_numerical/state_machine.rb
aasm-2.3.1 lib/aasm/state_machine.rb
aasm-2.3.0 lib/aasm/state_machine.rb
aasm-2.2.1 lib/aasm/state_machine.rb