Sha256: db1c332882e7d4280d734a3f0e13879edf3730930afc5a1dccbdbb7c56cc5b48
Contents?: true
Size: 811 Bytes
Versions: 1
Compression:
Stored size: 811 Bytes
Contents
module Unidom::Product::Concerns::AsSourceProductAssociating extend ActiveSupport::Concern included do |includer| has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id has_many :target_products, through: :target_product_associatings, source: :target def associate?(target, due_to: nil, at: Time.now) target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists? end def associate!(target, due_to: nil, at: Time.now, ordinal: 1) target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.first_or_create! ordinal: ordinal, opened_at: at end end module ClassMethods end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-product-1.3 | app/models/unidom/product/concerns/as_source_product_associating.rb |