Class: ActiveFedora::Associations::FilterAssociation

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

Instance Attribute Summary

Attributes inherited from CollectionAssociation

#proxy

Attributes inherited from Association

#inversed, #owner, #reflection

Instance Method Summary collapse

Methods inherited from CollectionAssociation

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

Methods inherited from Association

#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

Instance Method Details

#concat(records) ⇒ Object

Parameters:

  • records (Array)

    a list of records to append to the current association

Raises:

  • (ArgumentError)

    if one of the records doesn’t match the prescribed condition



17
18
19
20
# File 'lib/active_fedora/associations/filter_association.rb', line 17

def concat(records)
  records.flatten.each { |r| validate_assertion!(r) }
  extending_from.concat(records)
end

#count_recordsObject



27
28
29
# File 'lib/active_fedora/associations/filter_association.rb', line 27

def count_records
  ids_reader.length
end

#ids_readerObject



22
23
24
25
# File 'lib/active_fedora/associations/filter_association.rb', line 22

def ids_reader
  load_target
  super
end

#writer(records) ⇒ Object

Parameters:

  • records (Array)

    a list of records to replace the current association with

Raises:

  • (ArgumentError)

    if one of the records doesn’t match the prescribed condition



5
6
7
8
9
10
11
# File 'lib/active_fedora/associations/filter_association.rb', line 5

def writer(records)
  records.each { |r| validate_assertion!(r) }
  existing_matching_records.each do |r|
    extending_from.delete(r)
  end
  extending_from.concat(records)
end