Sha256: cb31f659cd29dd1e482f8822b19f276af9279094d3889922c3b432abb678d7f8

Contents?: true

Size: 495 Bytes

Versions: 2

Compression:

Stored size: 495 Bytes

Contents

module ShopDiscounts
  module Models
    module Product
      
      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

2 entries across 2 versions & 1 rubygems

Version Path
radiant-shop_discounts-extension-0.0.3 lib/shop_discounts/models/product.rb
radiant-shop_discounts-extension-0.0.1 lib/shop_discounts/models/product.rb