5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/formatting/currency.rb', line 5
def format_currency(record, amount_or_method, opts = {})
opts = Formatting.defaults.merge(opts)
format_string = opts.fetch(:format, "<amount> <currency>")
currency = opts.fetch(:currency) {
record.respond_to?(:currency) ? record.currency: nil
}
if amount_or_method.is_a?(Symbol)
amount = record.public_send(amount_or_method)
else
amount = amount_or_method
end
amount = format_number(amount, opts)
apply_format_string(format_string, amount, currency)
end
|