Module: AASM::Persistence::AirrecordPersistence

Included in:
AirctsAsStateMachine
Defined in:
lib/aircts_as_state_machine.rb

Overview

mix this in to taste

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/aircts_as_state_machine.rb', line 10

def self.included(base)
  base.extend AASM::Persistence::Base::ClassMethods
  base.extend ClassMethods

  base.class_eval do
    attr_accessor :_transition_changes
  end
end

Instance Method Details

#aasm_fire_event(state_machine_name, name, options, *args, &block) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/aircts_as_state_machine.rb', line 28

def aasm_fire_event(state_machine_name, name, options, *args, &block)
  return super unless options[:persist]

  transaction do
    super
  end
end

#aasm_read_state(name = :default) ⇒ Object



19
20
21
22
# File 'lib/aircts_as_state_machine.rb', line 19

def aasm_read_state(name = :default)
  state = self[self.class.aasm(name).attribute_name.to_s]
  state&.to_sym
end

#aasm_write_state_without_persistence(state, name = :default) ⇒ Object



24
25
26
# File 'lib/aircts_as_state_machine.rb', line 24

def aasm_write_state_without_persistence(state, name = :default)
  self[self.class.aasm(name).attribute_name.to_s] = state.to_s
end