Sha256: d5f3babf8f0d0638f4e1ffc760ba4ff99b555ea2edec40cc591de64b3e72715a
Contents?: true
Size: 813 Bytes
Versions: 6
Compression:
Stored size: 813 Bytes
Contents
module Unidom::Product::Concerns::AsTargetProduct extend ActiveSupport::Concern included do |includer| has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id has_many :source_products, through: :source_product_associatings, source: :source def is_associated?(source, due_to: nil, at: Time.now) source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists? end def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1) source_product_associatings.source_is(source).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
6 entries across 6 versions & 1 rubygems