Sha256: 126d858bce173efde0bc9250e3620ed4ae1c7133be0148ff57df7be8bc2e2a57

Contents?: true

Size: 739 Bytes

Versions: 5

Compression:

Stored size: 739 Bytes

Contents

module Unidom::Standard::Concerns::AsSourceStandard

  extend ActiveSupport::Concern

  included do |includer|

    has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id
    has_many :target_standards,    through:    :target_associatings,                    source:      :target

    def associate!(target, due_to: 'REVS', at: Time.now)
      target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at
    end

    def associate?(target, due_to: 'REVS', at: Time.now)
      target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.exists?
    end

  end

  module ClassMethods
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
unidom-standard-1.3.4 app/models/unidom/standard/concerns/as_source_standard.rb
unidom-standard-1.3.3 app/models/unidom/standard/concerns/as_source_standard.rb
unidom-standard-1.3.2 app/models/unidom/standard/concerns/as_source_standard.rb
unidom-standard-1.3.1 app/models/unidom/standard/concerns/as_source_standard.rb
unidom-standard-1.3 app/models/unidom/standard/concerns/as_source_standard.rb