Sha256: e154f1b7b2f52bb6c59b6a0f25601ee0f0bd98073090e280798fca81f7b93e14

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

module ActiveFedora::Orders
  class AggregationBuilder < ActiveFedora::Associations::Builder::Association
    self.valid_options = [:through, :class_name, :has_member_relation, :type_validator]

    def self.build(model, name, options)
      new(model, name, options).build
    end

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

    private

    def indirect_options
      {
        class_name: options[:class_name],
        type_validator: options[:type_validator]
      }.select{ |k, v| v.present? }
    end

    def has_member_relation
      options[:has_member_relation] || ::RDF::DC.hasPart
    end

    def inserted_content_relation
      ::RDF::Vocab::ORE::proxyFor
    end

    def proxy_class
      "ActiveFedora::Aggregation::Proxy"
    end

    def proxy_foreign_key
      :target
    end

    def contains_key
      options[:through]
    end

    def list_source_class
      "ActiveFedora::Aggregation::ListSource"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activefedora-aggregation-0.9.0 lib/active_fedora/orders/aggregation_builder.rb
activefedora-aggregation-0.8.1 lib/active_fedora/orders/aggregation_builder.rb
activefedora-aggregation-0.8.0 lib/active_fedora/orders/aggregation_builder.rb
activefedora-aggregation-0.7.0 lib/active_fedora/orders/aggregation_builder.rb
activefedora-aggregation-0.6.0 lib/active_fedora/orders/aggregation_builder.rb
activefedora-aggregation-0.5.0 lib/active_fedora/orders/aggregation_builder.rb