Sha256: 3e56c64c889563455f4ae4b6334d798ff15e1b4323816ee2b480695b8ddeb80e

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

module Unidom::Product::Concerns::AsTargetProductAssociating

  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)
      warn "The Unidom::Product::Concerns::AsTargetProductAssociating#is_associated? method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsTargetProduct#is_associated? method instead."
      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)
      warn "The Unidom::Product::Concerns::AsTargetProductAssociating#is_associated! method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsTargetProduct#is_associated! method instead."
      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

Version Path
unidom-product-1.6 app/models/unidom/product/concerns/as_target_product_associating.rb
unidom-product-1.5.1 app/models/unidom/product/concerns/as_target_product_associating.rb
unidom-product-1.5 app/models/unidom/product/concerns/as_target_product_associating.rb
unidom-product-1.4.2 app/models/unidom/product/concerns/as_target_product_associating.rb
unidom-product-1.4.1 app/models/unidom/product/concerns/as_target_product_associating.rb
unidom-product-1.4 app/models/unidom/product/concerns/as_target_product_associating.rb