Sha256: 79573a1c49bd2d85f329dc14a603d2cc6f58d897bb0678bfa3071f6eef020045

Contents?: true

Size: 499 Bytes

Versions: 6

Compression:

Stored size: 499 Bytes

Contents

module ShopDiscounts
  module Models
    module ShopProduct
      
      def self.included(base)
        base.class_eval do
          after_create                  :assign_discounts
          
          # Assigns discounts based off categories discounts
          def assign_discounts
            category.discounts.each do |discount|      
              ShopDiscountable.create(:discount => discount, :discounted => self)
            end
          end
        end
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
radiant-shop_discounts-extension-0.0.10 lib/shop_discounts/models/shop_product.rb
radiant-shop_discounts-extension-0.0.9 lib/shop_discounts/models/shop_product.rb
radiant-shop_discounts-extension-0.0.8 lib/shop_discounts/models/shop_product.rb
radiant-shop_discounts-extension-0.0.7 lib/shop_discounts/models/shop_product.rb
radiant-shop_discounts-extension-0.0.6 lib/shop_discounts/models/shop_product.rb
radiant-shop_discounts-extension-0.0.4 lib/shop_discounts/models/shop_product.rb