Class: TransactionType
- Inherits:
-
Object
- Object
- TransactionType
- Includes:
- EnumField::DefineEnum
- Defined in:
- app/models/enums/transaction_type.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #css_class ⇒ Object
- #description(params = {}) ⇒ Object
-
#initialize(code) ⇒ TransactionType
constructor
A new instance of TransactionType.
- #title(params = {}) ⇒ Object
- #translate(transaction) ⇒ Object
Constructor Details
#initialize(code) ⇒ TransactionType
Returns a new instance of TransactionType.
8 9 10 |
# File 'app/models/enums/transaction_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/transaction_type.rb', line 6 def code @code end |
Instance Method Details
#css_class ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/enums/transaction_type.rb', line 30 def css_class # case @code # when :income then 'paid' # when :payment then 'paid' # when :full_revert then 'paid' # when :partial_revert then 'paid' # when :reserv then 'paid' # else 'paid' # end 'paid' end |
#description(params = {}) ⇒ Object
16 17 18 |
# File 'app/models/enums/transaction_type.rb', line 16 def description(params = {}) I18n.t(code, params.merge(scope: [:account, :transaction_type, :description])) end |
#title(params = {}) ⇒ Object
12 13 14 |
# File 'app/models/enums/transaction_type.rb', line 12 def title(params = {}) I18n.t(code, params.merge(scope: [:account, :transaction_type, :title])) end |
#translate(transaction) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/models/enums/transaction_type.rb', line 20 def translate(transaction) = { order_id: transaction.order.number, amount: transaction.amount, content: transaction.content } I18n.t(code, .merge(scope: [:account, :transactions])) end |