Class: Spree::Price
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/price.rb
Instance Method Summary collapse
-
#money ⇒ Spree::Money
This price as a Spree::Money object.
-
#price ⇒ Object
An alias for #amount.
-
#price=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
-
#variant ⇒ Spree::Variant
This price’s variant.
Methods included from DisplayMoney
Methods inherited from Base
Methods included from Spree::Preferences::Preferable
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#money ⇒ Spree::Money
Returns this price as a Spree::Money object.
17 18 19 |
# File 'app/models/spree/price.rb', line 17 def money Spree::Money.new(amount || 0, { currency: currency }) end |
#price ⇒ Object
An alias for #amount
22 23 24 |
# File 'app/models/spree/price.rb', line 22 def price amount end |
#price=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
30 31 32 |
# File 'app/models/spree/price.rb', line 30 def price=(price) self[:amount] = Spree::LocalizedNumber.parse(price) end |
#variant ⇒ Spree::Variant
Note:
This returns the variant regardless of whether it was soft deleted.
Returns this price’s variant.
37 38 39 |
# File 'app/models/spree/price.rb', line 37 def variant Spree::Variant.unscoped { super } end |