Sha256: 9e28119494afe43e8da653a342b7a56a5df7fef2eba46d80e6b3c39136f010c1

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

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

6 entries across 6 versions & 1 rubygems

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