Class: Io::Flow::V0::Models::Money
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Money
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Money represents an amount in a given currency
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Money
constructor
A new instance of Money.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Money
Returns a new instance of Money.
36599 36600 36601 36602 36603 36604 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36599 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:amount, :currency], 'Money') @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
36597 36598 36599 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36597 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
36597 36598 36599 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36597 def currency @currency end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
36610 36611 36612 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36610 def copy(incoming={}) Money.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
36614 36615 36616 36617 36618 36619 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36614 def to_hash { :amount => amount, :currency => currency } end |
#to_json ⇒ Object
36606 36607 36608 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36606 def to_json JSON.dump(to_hash) end |