Class: Comable::Payment

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.state_namesObject



55
56
57
# File 'app/models/comable/payment.rb', line 55

def state_names
  state_machine.states.keys
end

Instance Method Details

#complete!Object



70
71
72
73
# File 'app/models/comable/payment.rb', line 70

def complete!
  provider_complete!
  touch :completed_at
end

#completed?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/comable/payment.rb', line 66

def completed?
  completed_at?
end

#current_feeObject



75
76
77
# File 'app/models/comable/payment.rb', line 75

def current_fee
  payment_method.try(:fee) || 0
end

#stated?(target_state) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'app/models/comable/payment.rb', line 60

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