Method: Exchange::Typecasting#attribute
- Defined in:
-
lib/exchange/typecasting.rb,
lib/exchange/typecasting.rb
Installs a money setter
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/exchange/typecasting.rb', line 54 def install_money_getter attribute, ={} define_method :"#{attribute}_with_exchange_typecasting" do currency = evaluate_money_option([:currency]) if [:currency] test_for_currency_error(currency, attribute) time = evaluate_money_option([:at]) if [:at] if value = send(:"#{attribute}_without_exchange_typecasting") Exchange::Money.new(value) do |c| c.currency = currency c.time = time if time end end end exchange_typecasting_alias_method_chain attribute end |