Sha256: f8565c17d7f0a9366983ba99d812b419e1bf7ddb3a98e33710af9eab770be95e

Contents?: true

Size: 574 Bytes

Versions: 20

Compression:

Stored size: 574 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)
      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)
      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

20 entries across 20 versions & 1 rubygems

Version Path
unidom-party-1.9.6 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.5 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.4 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.3 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.2 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9.1 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.9 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8.5 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8.4 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8.3 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8.2 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8.1 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.8 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.7.2 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.7.1 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.7 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.6 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.5 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.4 app/models/unidom/party/concerns/as_target_party.rb
unidom-party-1.3 app/models/unidom/party/concerns/as_target_party.rb