Sha256: 2ae0dd56c2070ff30169b74861297feedfa4024ca3ec8b8ae27de7a921c7ea68

Contents?: true

Size: 1.59 KB

Versions: 54

Compression:

Stored size: 1.59 KB

Contents

module ActiveFedora::Associations::Builder
  class Aggregation < ActiveFedora::Associations::Builder::Association
    def self.valid_options(_options)
      [:through, :class_name, :has_member_relation, :type_validator]
    end

    def self.build(model, name, options)
      model.indirectly_contains name, { has_member_relation: has_member_relation(options), through: proxy_class, foreign_key: proxy_foreign_key, inserted_content_relation: inserted_content_relation }.merge(indirect_options(options))
      model.has_subresource contains_key(options), class_name: list_source_class
      model.orders name, through: contains_key(options)
    end

    def self.indirect_options(options)
      {
        class_name: options[:class_name],
        type_validator: options[:type_validator]
      }.select { |_k, v| v.present? }
    end
    private_class_method :indirect_options

    def self.has_member_relation(options)
      options[:has_member_relation] || ::RDF::Vocab::DC.hasPart
    end
    private_class_method :has_member_relation

    def self.inserted_content_relation
      ::RDF::Vocab::ORE.proxyFor
    end
    private_class_method :inserted_content_relation

    def self.proxy_class
      "ActiveFedora::Aggregation::Proxy"
    end
    private_class_method :proxy_class

    def self.proxy_foreign_key
      :target
    end
    private_class_method :proxy_foreign_key

    def self.contains_key(options)
      options[:through]
    end
    private_class_method :contains_key

    def self.list_source_class
      "ActiveFedora::Aggregation::ListSource"
    end
    private_class_method :list_source_class
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
active-fedora-15.0.1 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-15.0.0 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-14.0.1 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-14.0.0 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.3.0 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-12.2.4 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.7 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.5 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.4 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-12.2.3 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.3 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.2 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.2.0 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-13.1.3 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-11.5.6 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-12.2.2 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-11.2.1 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-12.2.1 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-12.0.3 lib/active_fedora/associations/builder/aggregation.rb
active-fedora-11.5.5 lib/active_fedora/associations/builder/aggregation.rb