Class: PanStuff::Serializer::MoneySerializer
- Inherits:
-
Object
- Object
- PanStuff::Serializer::MoneySerializer
show all
- Includes:
- ObjectSerializer
- Defined in:
- lib/pan_stuff/serializer/money_serializer.rb
Constant Summary
Constants included
from Base
Base::TRANSFORMS_MAPPING
Instance Method Summary
collapse
#data, #initialize, #meta, #serializable_hash!
Methods included from Base
#as_json, #run_key_transform!, #serializable_hash!, #to_h
Instance Method Details
#amount(record) ⇒ Object
18
19
20
|
# File 'lib/pan_stuff/serializer/money_serializer.rb', line 18
def amount(record)
record.to_f
end
|
#cents(record) ⇒ Object
14
15
16
|
# File 'lib/pan_stuff/serializer/money_serializer.rb', line 14
def cents(record)
record.cents
end
|
#currency(record) ⇒ Object
22
23
24
|
# File 'lib/pan_stuff/serializer/money_serializer.rb', line 22
def currency(record)
record.currency.iso_code
end
|
#formatted_text(record) ⇒ Object
26
27
28
|
# File 'lib/pan_stuff/serializer/money_serializer.rb', line 26
def formatted_text(record)
record.format(symbol: "#{record.currency.symbol} ")
end
|
#symbol(record) ⇒ Object
30
31
32
|
# File 'lib/pan_stuff/serializer/money_serializer.rb', line 30
def symbol(record)
record.currency.symbol
end
|