Class: ActiveFedora::Filter::Association

Inherits:
Associations::CollectionAssociation
  • Object
show all
Defined in:
lib/active_fedora/filter/association.rb

Instance Method Summary collapse

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



19
20
21
22
# File 'lib/active_fedora/filter/association.rb', line 19

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

#count_recordsObject



29
30
31
# File 'lib/active_fedora/filter/association.rb', line 29

def count_records
  ids_reader.length
end

#delete(records) ⇒ Object



13
14
15
# File 'lib/active_fedora/filter/association.rb', line 13

def delete(records)
  extending_from.delete(records)
end

#ids_readerObject



24
25
26
27
# File 'lib/active_fedora/filter/association.rb', line 24

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/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