Sha256: cff9ebf871e4b488cb09403a31fea5684f4530982ffa05d1b24bac53604e8f79

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module ActiveFedora::Associations::Builder
  class IndirectlyContains < CollectionAssociation # :nodoc:
    def self.macro
      :indirectly_contains
    end

    def self.valid_options(options)
      super + [:has_member_relation, :is_member_of_relation, :inserted_content_relation, :foreign_key, :through] - [:predicate]
    end

    def self.define_readers(mixin, name)
      super

      mixin.redefine_method("#{name.to_s.singularize}_ids") do
        association(name).ids_reader
      end
    end

    def self.validate_options(options)
      super

      raise ArgumentError, "You must specify a predicate for #{name}" if !options[:has_member_relation] && !options[:is_member_of_relation]
      raise ArgumentError, "Predicate must be a kind of RDF::URI" if !options[:has_member_relation].is_a?(RDF::URI) && !options[:is_member_of_relation].is_a?(RDF::URI)
      raise ArgumentError, "Missing :through option" unless options[:through]
      raise ArgumentError, "Missing :foreign_key option" unless options[:foreign_key]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active-fedora-15.0.1 lib/active_fedora/associations/builder/indirectly_contains.rb
active-fedora-15.0.0 lib/active_fedora/associations/builder/indirectly_contains.rb
active-fedora-14.0.1 lib/active_fedora/associations/builder/indirectly_contains.rb
active-fedora-14.0.0 lib/active_fedora/associations/builder/indirectly_contains.rb