Class: Atreides::Product
- Includes:
- Base::AasmStates, Base::Taggable, Extendable
- Defined in:
- app/models/atreides/product.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_price ⇒ Object
- #set_slug ⇒ Object
-
#size_for_name(name) ⇒ Object
Instance Methods.
- #sold_out? ⇒ Boolean
Methods included from Base::AasmStates
Methods included from Base::Taggable
Methods inherited from Base
Class Method Details
.base_class ⇒ Object
56 57 58 |
# File 'app/models/atreides/product.rb', line 56 def base_class self end |
Instance Method Details
#check_price ⇒ Object
34 35 36 |
# File 'app/models/atreides/product.rb', line 34 def check_price errors.add(:price, "must be greater than zero") if price.zero? and !pending? end |
#set_slug ⇒ Object
47 48 49 50 |
# File 'app/models/atreides/product.rb', line 47 def set_slug # Set slug self.slug = title.to_s.parameterize if !slug? end |
#size_for_name(name) ⇒ Object
Instance Methods
64 65 66 |
# File 'app/models/atreides/product.rb', line 64 def size_for_name(name) sizes.first(:conditions => {:name => name}) end |
#sold_out? ⇒ Boolean
68 69 70 |
# File 'app/models/atreides/product.rb', line 68 def sold_out? self.sizes.sum(:qty).zero? end |