Class: Atreides::Product

Inherits:
Base
  • Object
show all
Includes:
Base::AasmStates, Base::Taggable, Extendable
Defined in:
app/models/atreides/product.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::AasmStates

included

Methods included from Base::Taggable

included

Methods inherited from Base

#dom_id, #to_param

Class Method Details

.base_classObject



56
57
58
# File 'app/models/atreides/product.rb', line 56

def base_class
  self
end

Instance Method Details

#check_priceObject



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_slugObject



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

Returns:

  • (Boolean)


68
69
70
# File 'app/models/atreides/product.rb', line 68

def sold_out?
  self.sizes.sum(:qty).zero?
end