Class: CommissionType
- Inherits:
-
Object
- Object
- CommissionType
- Includes:
- EnumField::DefineEnum
- Defined in:
- app/models/enums/commission_type.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #checkpoint(commission) ⇒ Object
-
#initialize(code) ⇒ CommissionType
constructor
A new instance of CommissionType.
- #title ⇒ Object
Constructor Details
#initialize(code) ⇒ CommissionType
Returns a new instance of CommissionType.
8 9 10 |
# File 'app/models/enums/commission_type.rb', line 8 def initialize(code) @code = code.to_sym end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'app/models/enums/commission_type.rb', line 6 def code @code end |
Instance Method Details
#checkpoint(commission) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/enums/commission_type.rb', line 16 def checkpoint(commission) checkpoint_from = orders_total? ? commission.checkpoint_from.to_f : commission.checkpoint_from.to_i checkpoint_to = orders_total? ? commission.checkpoint_to.to_f : commission.checkpoint_to.to_i if commission.checkpoint_to.blank? "#{checkpoint_from}+" elsif commission.checkpoint_from.blank? "0 - #{checkpoint_to}" else "#{checkpoint_from} - #{checkpoint_to}" end end |
#title ⇒ Object
12 13 14 |
# File 'app/models/enums/commission_type.rb', line 12 def title I18n.t(code, scope: [:affilate, :commission_type]) end |