Class: PiResources::Serializer::MoneySerializer
- Inherits:
-
Object
- Object
- PiResources::Serializer::MoneySerializer
show all
- Includes:
- ObjectSerializer
- Defined in:
- lib/pi_resources/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
20
21
22
|
# File 'lib/pi_resources/serializer/money_serializer.rb', line 20
def amount(record)
record.to_f
end
|
#cents(record) ⇒ Object
16
17
18
|
# File 'lib/pi_resources/serializer/money_serializer.rb', line 16
def cents(record)
record.cents
end
|
#currency(record) ⇒ Object
24
25
26
|
# File 'lib/pi_resources/serializer/money_serializer.rb', line 24
def currency(record)
record.currency.iso_code
end
|
#formatted_text(record) ⇒ Object
28
29
30
|
# File 'lib/pi_resources/serializer/money_serializer.rb', line 28
def formatted_text(record)
record.format(symbol: "#{record.currency.symbol} ")
end
|
#symbol(record) ⇒ Object
32
33
34
|
# File 'lib/pi_resources/serializer/money_serializer.rb', line 32
def symbol(record)
record.currency.symbol
end
|