Class: AasmHistory::HistoryCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/aasm_history/history_creator.rb

Instance Method Summary collapse

Constructor Details

#initialize(object, state, previous_state) ⇒ HistoryCreator

Returns a new instance of HistoryCreator.



3
4
5
6
7
# File 'lib/aasm_history/history_creator.rb', line 3

def initialize object, state, previous_state
  @object = object
  @state = state
  @previous_state = previous_state
end

Instance Method Details

#attributesObject



17
18
19
# File 'lib/aasm_history/history_creator.rb', line 17

def attributes
  {state: @state, previous_state: @previous_state, stateable: @object}
end

#createObject



9
10
11
# File 'lib/aasm_history/history_creator.rb', line 9

def create
  klass.create! attributes
end

#klassObject



13
14
15
# File 'lib/aasm_history/history_creator.rb', line 13

def klass
  @klass ||= AASM::StateMachine[@object.class].config.history_class.constantize
end