Sha256: 0ce14c9150d940944b2c465d40c53cb86a1765f71f6bd6e8eac246fc639b18ad
Contents?: true
Size: 427 Bytes
Versions: 4
Compression:
Stored size: 427 Bytes
Contents
module Comable class Product < ActiveRecord::Base include Comable::SkuItem has_many :stocks, class_name: Comable::Stock.name, foreign_key: table_name.singularize.foreign_key after_create :create_stock def unsold? stocks.activated.unsold.exists? end def soldout? !unsold? end private def create_stock stocks.create(code: code) unless stocks.exists? end end end
Version data entries
4 entries across 4 versions & 1 rubygems