module AasmProgressable::ModelMixin

Public Instance Methods

aasm_state_order() click to toggle source

Instance gettor to return the state order for the model

# File lib/aasm_progressable/model_mixin.rb, line 12
def aasm_state_order
  self.class.get_aasm_state_order
end
have_completed?(state) click to toggle source
# File lib/aasm_progressable/model_mixin.rb, line 16
def have_completed?(state)
  current_index, target_index = state_index(self.aasm.current_state, state)
  current_index > target_index
end
have_not_completed?(state) click to toggle source
# File lib/aasm_progressable/model_mixin.rb, line 21
def have_not_completed?(state)
  not have_completed?(state)
end
have_not_started?(state) click to toggle source
# File lib/aasm_progressable/model_mixin.rb, line 30
def have_not_started?(state)
  not have_started?(state)
end
have_started?(state) click to toggle source
# File lib/aasm_progressable/model_mixin.rb, line 25
def have_started?(state)
  current_index, target_index = state_index(self.aasm.current_state, state)
  current_index >= target_index
end

Private Instance Methods

state_index(*states) click to toggle source

Returns an array of zero-index state indices, where each index indicates the state’s position in the ordered state collection.

# File lib/aasm_progressable/model_mixin.rb, line 49
def state_index(*states)
  states.map { |state| self.aasm_state_order.index(state) }
end