Sha256: 15779490a26231eaee294ca6b5908f5df2e7b260f69eb383c1a56b5fd2651b5e

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

module ActiveFedora::Aggregation
  class Builder < ActiveFedora::Associations::Builder::CollectionAssociation
    include ActiveFedora::AutosaveAssociation::AssociationBuilderExtension
    self.macro = :aggregation

    def build
      reflection = super
      model.belongs_to :head, predicate: ::RDF::Vocab::IANA['first'], class_name: 'ActiveFedora::Aggregation::Proxy'
      model.belongs_to :tail, predicate: ::RDF::Vocab::IANA.last, class_name: 'ActiveFedora::Aggregation::Proxy'

      model.include AggregationExtension
      reflection
    end

    def self.define_readers(mixin, name)
      super
      mixin.redefine_method("#{name.to_s.singularize}_ids") do
        association(name).ids_reader
      end
      mixin.redefine_method("ordered_#{name.to_s.pluralize}") do
        association(name).ordered_reader
      end
    end

    def self.define_writers(mixin, name)
      super
      mixin.redefine_method("#{name.to_s.singularize}_ids=") do |ids|
        association(name).ids_writer(ids)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activefedora-aggregation-0.9.0 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.8.1 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.8.0 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.7.0 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.6.0 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.5.0 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.4.2 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.4.1 lib/active_fedora/aggregation/builder.rb
activefedora-aggregation-0.4.0 lib/active_fedora/aggregation/builder.rb