Module: CustomMoney::InstanceMethods
- Defined in:
- lib/apl-library/custom_money.rb
Instance Method Summary collapse
- #raw_data_to_money(value) ⇒ Object
- #round_off_raw_data(value) ⇒ Object
- #validate_curr(value) ⇒ Object
Instance Method Details
#raw_data_to_money(value) ⇒ Object
30 31 32 |
# File 'lib/apl-library/custom_money.rb', line 30 def raw_data_to_money(value) Money.new(value) rescue nil end |
#round_off_raw_data(value) ⇒ Object
34 35 36 |
# File 'lib/apl-library/custom_money.rb', line 34 def round_off_raw_data(value) raw_data_to_money(value).try(:to_d) end |
#validate_curr(value) ⇒ Object
38 39 40 41 |
# File 'lib/apl-library/custom_money.rb', line 38 def validate_curr(value) errors.add(:currency, "Invalid currency - #{value}") if (Money::Currency.find(value)).nil? value end |