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.
38271 38272 38273 38274 38275 38276 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38271 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.
38269 38270 38271 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38269 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
38269 38270 38271 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38269 def currency @currency end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
38282 38283 38284 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38282 def copy(incoming={}) Money.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
38286 38287 38288 38289 38290 38291 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38286 def to_hash { :amount => amount, :currency => currency } end |
#to_json ⇒ Object
38278 38279 38280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38278 def to_json JSON.dump(to_hash) end |