Class: ActiveFedora::Associations::Builder::IndirectlyContains

Inherits:
CollectionAssociation show all
Defined in:
lib/active_fedora/associations/builder/indirectly_contains.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from CollectionAssociation

#proxy

Attributes inherited from Association

#inversed, #owner, #reflection, #target

Class Method Summary collapse

Methods inherited from CollectionAssociation

#add_to_target, #any?, #build, #concat, #concat_records, #count, #create, #create!, #delete, #delete_all, #destroy, #destroy_all, #empty?, #find, #first, #ids_reader, #ids_writer, #include?, #last, #load_from_solr, #load_target, #null_scope?, #reader, #replace, #reset, #scope, #select, #size, #target=, #to_ary, #writer

Methods inherited from Association

#association_scope, #initialize, #initialize_attributes, #load_target, #loaded!, #loaded?, #reload, #reset, #reset_scope, #scope, #set_inverse_instance, #stale_target?, #target_scope

Constructor Details

This class inherits a constructor from ActiveFedora::Associations::Association

Class Method Details

.define_readers(mixin, name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/active_fedora/associations/builder/indirectly_contains.rb', line 11

def self.define_readers(mixin, name)
  super

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

.macroObject



3
4
5
# File 'lib/active_fedora/associations/builder/indirectly_contains.rb', line 3

def self.macro
  :indirectly_contains
end

.valid_options(options) ⇒ Object



7
8
9
# File 'lib/active_fedora/associations/builder/indirectly_contains.rb', line 7

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

.validate_options(options) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
# File 'lib/active_fedora/associations/builder/indirectly_contains.rb', line 19

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