Module: MoneyWithDate::ActiveRecord::Monetizable

Defined in:
lib/money_with_date/active_record/monetizable.rb

Instance Method Summary collapse

Instance Method Details

#read_monetized(name, subunit_name, options = {}, *args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/money_with_date/active_record/monetizable.rb', line 6

def read_monetized(name, subunit_name, options = {}, *args)
  money = super
  date = find_date_for(options[:with_model_date], options[:with_date])

  if money&.date == date
    money
  else
    instance_variable_set("@#{name}", money&.with_date(date))
  end
end