Class: Comable::Stock

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Decoratable
Defined in:
app/models/comable/stock.rb

Instance Method Summary collapse

Methods included from Decoratable

included

Instance Method Details

#decrement_quantity!Object



24
25
26
27
28
29
# File 'app/models/comable/stock.rb', line 24

def decrement_quantity!
  with_lock do
    # TODO: カラムマッピングのdecrementメソッドへの対応
    update_attributes!(quantity: quantity.pred)
  end
end

#soldout?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/comable/stock.rb', line 20

def soldout?
  !unsold?
end

#unsold?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'app/models/comable/stock.rb', line 14

def unsold?
  return false if product_id_num.nil?
  return false if quantity.nil?
  quantity > 0
end