Module: ErpProducts::Extensions::ActiveRecord::ActsAsProductOffer::InstanceMethods

Defined in:
lib/erp_products/extensions/active_record/acts_as_product_offer.rb

Instance Method Summary collapse

Instance Method Details

#destroy_product_offerObject



47
48
49
# File 'lib/erp_products/extensions/active_record/acts_as_product_offer.rb', line 47

def destroy_product_offer
  self.product_offer.destroy if (self.product_offer && !self.product_offer.frozen?)
end

#initialize_product_offerObject



33
34
35
36
37
38
39
40
# File 'lib/erp_products/extensions/active_record/acts_as_product_offer.rb', line 33

def initialize_product_offer
  if self.new_record? && self.product_offer.nil?
    product_offer = ProductOffer.new
    self.product_offer = product_offer
    product_offer.save
    self.save
  end
end

#save_product_offerObject



42
43
44
45
# File 'lib/erp_products/extensions/active_record/acts_as_product_offer.rb', line 42

def save_product_offer
  self.product_offer.description = self.description
  self.product_offer.save
end