Sha256: 8600e466c62c9c339c60e1cf98e06c7126b536d656beaf939c34e1ebbcd70942

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

##
# As Target Standard 是目标标准的领域逻辑关注点。

module Unidom::Standard::Concerns::AsTargetStandard

  extend  ActiveSupport::Concern
  include Unidom::Common::Concerns::ArgumentValidation

  included do |includer|

    has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id
    has_many :source_standards,    through:    :source_associatings,                    source:      :source

    def is_associated!(source, due_to: 'REVS', at: Time.now)

      assert_present! :source, source

      source_associatings.source_is(source).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at

    end

    def is_associated?(source, due_to: 'REVS', at: Time.now)
      source_associatings.source_is(source).association_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-standard-2.0 app/models/unidom/standard/concerns/as_target_standard.rb
unidom-standard-1.4.9 app/models/unidom/standard/concerns/as_target_standard.rb
unidom-standard-1.4.8 app/models/unidom/standard/concerns/as_target_standard.rb