Class: Spree::Price

Inherits:
Base
  • Object
show all
Extended by:
DisplayMoney
Defined in:
app/models/spree/price.rb

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Methods inherited from Base

page

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

#moneySpree::Money

Returns this price as a Spree::Money object.

Returns:



15
16
17
# File 'app/models/spree/price.rb', line 15

def money
  Spree::Money.new(amount || 0, { currency: currency })
end

#priceObject

An alias for #amount



20
21
22
# File 'app/models/spree/price.rb', line 20

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.

Parameters:

  • price (String, #to_d)

    a new amount



28
29
30
# File 'app/models/spree/price.rb', line 28

def price=(price)
  self[:amount] = Spree::LocalizedNumber.parse(price)
end

#variantSpree::Variant

Note:

This returns the variant regardless of whether it was soft deleted.

Returns this price’s variant.

Returns:



35
36
37
# File 'app/models/spree/price.rb', line 35

def variant
  Spree::Variant.unscoped { super }
end