Sha256: 87d38d244564e605e3474d17dad919a562c161a854fe324ad39b04fe7eddb76e

Contents?: true

Size: 792 Bytes

Versions: 3

Compression:

Stored size: 792 Bytes

Contents

module Unidom::Party::Concerns::AsTargetParty

  extend ActiveSupport::Concern

  included do |includer|

    has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party

    def is_related!(to: nil, due_to: nil, at: Time.now)

      assert_present! :to,     to
      assert_present! :due_to, due_to
      assert_present! :at,     at

      source_party_relations.create! source_party: to, linkage_code: due_to, opened_at: at

    end

    def is_related?(to: nil, due_to: nil, at: Time.now)

      assert_present! :to,     to
      assert_present! :due_to, due_to
      assert_present! :at,     at

      source_party_relations.source_party_is(to).linkage_coded_as(due_to).valid_at(now: at).alive.exists?

    end

  end

  module ClassMethods
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unidom-party-2.0 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.8 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.7 app/models/unidom/party/concerns/as_target_party.rb