Class: Comable::Shipment

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Ransackable
Defined in:
app/models/comable/shipment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.state_namesObject



52
53
54
# File 'app/models/comable/shipment.rb', line 52

def state_names
  state_machine.states.keys
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'app/models/comable/shipment.rb', line 63

def completed?
  state?(:completed) || state?(:resumed)
end

#stated?(target_state) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
# File 'app/models/comable/shipment.rb', line 57

def stated?(target_state)
  target_state_index = self.class.state_names.index(target_state.to_sym)
  current_state_index = self.class.state_names.index(state_name)
  target_state_index < current_state_index
end