Module: MoneyWithDate::ClassMethods
- Defined in:
- lib/money_with_date/class_methods.rb
Instance Attribute Summary collapse
-
#date_determines_equality ⇒ Object
Returns the value of attribute date_determines_equality.
- #default_date ⇒ Object
-
#default_date_column ⇒ Object
Returns the value of attribute default_date_column.
Instance Method Summary collapse
- #add_rate(from_currency, to_currency, rate, date = ::Money.default_date) ⇒ Object
- #parse_date(date) ⇒ Object
Instance Attribute Details
#date_determines_equality ⇒ Object
Returns the value of attribute date_determines_equality.
5 6 7 |
# File 'lib/money_with_date/class_methods.rb', line 5 def date_determines_equality @date_determines_equality end |
#default_date ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/money_with_date/class_methods.rb', line 10 def default_date if @default_date.respond_to?(:call) @default_date.call else @default_date end end |
#default_date_column ⇒ Object
Returns the value of attribute default_date_column.
6 7 8 |
# File 'lib/money_with_date/class_methods.rb', line 6 def default_date_column @default_date_column end |
Instance Method Details
#add_rate(from_currency, to_currency, rate, date = ::Money.default_date) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/money_with_date/class_methods.rb', line 18 def add_rate(from_currency, to_currency, rate, date = ::Money.default_date) if ::Money.default_bank.method(:add_rate).parameters.size == 3 ::Money.default_bank.add_rate(from_currency, to_currency, rate) else ::Money.default_bank.add_rate(from_currency, to_currency, rate, date) end end |
#parse_date(date) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/money_with_date/class_methods.rb', line 26 def parse_date(date) return ::Money.default_date unless date return date.to_date if date.respond_to?(:to_date) ::Date.parse(date) rescue ArgumentError, TypeError, ::Date::Error # rubocop:disable Lint/ShadowedException raise ArgumentError, "#{date.inspect} cannot be parsed as Date" end |