Sha256: 82508e2fd8361dda8ed92aea5262d641c615fdc30c2568c803cd655ca31c3ae7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module ActiveFedora::Orders
  class AggregationBuilder < 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.contains contains_key(options), class_name: list_source_class
      model.orders name, through: contains_key(options)
    end

    private

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

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

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

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

    def self.proxy_foreign_key
      :target
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activefedora-aggregation-0.10.0 lib/active_fedora/orders/aggregation_builder.rb