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.
19254 19255 19256 19257 19258 19259 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19254 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.
19252 19253 19254 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19252 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
19252 19253 19254 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19252 def currency @currency end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
19265 19266 19267 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19265 def copy(incoming={}) Money.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
19269 19270 19271 19272 19273 19274 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19269 def to_hash { :amount => amount, :currency => currency } end |
#to_json ⇒ Object
19261 19262 19263 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19261 def to_json JSON.dump(to_hash) end |