Class: Amountable::VirtualAmount
- Inherits:
-
Object
- Object
- Amountable::VirtualAmount
- Includes:
- ActiveModel::Model, Operations
- Defined in:
- lib/amountable/virtual_amount.rb
Instance Attribute Summary collapse
-
#amountable ⇒ Object
Returns the value of attribute amountable.
-
#name ⇒ Object
Returns the value of attribute name.
-
#persistable ⇒ Object
Returns the value of attribute persistable.
-
#value_cents ⇒ Object
Returns the value of attribute value_cents.
-
#value_currency ⇒ Object
Returns the value of attribute value_currency.
Instance Method Summary collapse
Methods included from Operations
Instance Attribute Details
#amountable ⇒ Object
Returns the value of attribute amountable.
7 8 9 |
# File 'lib/amountable/virtual_amount.rb', line 7 def amountable @amountable end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/amountable/virtual_amount.rb', line 7 def name @name end |
#persistable ⇒ Object
Returns the value of attribute persistable.
7 8 9 |
# File 'lib/amountable/virtual_amount.rb', line 7 def persistable @persistable end |
#value_cents ⇒ Object
Returns the value of attribute value_cents.
7 8 9 |
# File 'lib/amountable/virtual_amount.rb', line 7 def value_cents @value_cents end |
#value_currency ⇒ Object
Returns the value of attribute value_currency.
7 8 9 |
# File 'lib/amountable/virtual_amount.rb', line 7 def value_currency @value_currency end |
Instance Method Details
#new_record? ⇒ Boolean
22 23 24 |
# File 'lib/amountable/virtual_amount.rb', line 22 def new_record? true end |
#persisted? ⇒ Boolean
26 27 28 |
# File 'lib/amountable/virtual_amount.rb', line 26 def persisted? false end |
#save ⇒ Object
30 31 32 33 |
# File 'lib/amountable/virtual_amount.rb', line 30 def save raise StandardError.new("Can't persist amount to database") if persistable == false super end |
#value ⇒ Object
13 14 15 |
# File 'lib/amountable/virtual_amount.rb', line 13 def value Money.new(value_cents, value_currency) end |
#value=(val) ⇒ Object
17 18 19 20 |
# File 'lib/amountable/virtual_amount.rb', line 17 def value=(val) self.value_cents = value.fractional self.value_currency = value.currency.iso_code end |