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:



17
18
19
# File 'app/models/spree/price.rb', line 17

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

#priceObject

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.

Parameters:

  • price (String, #to_d)

    a new amount



30
31
32
# File 'app/models/spree/price.rb', line 30

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:



37
38
39
# File 'app/models/spree/price.rb', line 37

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