module
Money::Currency::Converter
Overview
Currency converter to be used with JSON and YAML serialization.
require "json"
require "yaml"
record FooWithCurrency, currency : Money::Currency do
include JSON::Serializable
include YAML::Serializable
@[JSON::Field(converter: Money::Currency::Converter)]
@[YAML::Field(converter: Money::Currency::Converter)]
@currency : Money::Currency
end
foo = FooWithCurrency.new(Money::Currency.find("USD"))
foo.to_json # => "{\"currency\":\"USD\"}"
foo.to_yaml # => "currency: USD"
Extended Modules
Defined in:
money/currency/converter.crInstance Method Summary
- #from_json(pull : JSON::PullParser) : Currency
- #from_yaml(ctx : YAML::ParseContext, node : YAML::Nodes::Node) : Currency
- #to_json(currency : Currency, json : JSON::Builder)
- #to_yaml(currency : Currency, yaml : YAML::Nodes::Builder)