Module: CurrencyConversion::Model::ClassMethods

Defined in:
lib/currency_conversion/model.rb

Instance Method Summary collapse

Instance Method Details

#conversion_fields(*fields) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/currency_conversion/model.rb', line 9

def conversion_fields(*fields)
  fields.each do |field|
    define_method "#{field.to_s}_to" do |args, from="usd"|
      return self.send(field) if args.nil? || ( args == "usd" && from == "usd"  )
      make_transaction self.send(field), from, args
    end
  end
end