class ActiveFedora::Filter::Association
Public Instance Methods
concat(records)
click to toggle source
@param [Array] records a list of records to append to the current association @raise [ArgumentError] if one of the records doesn’t match the prescribed condition
# 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_records()
click to toggle source
# File lib/active_fedora/filter/association.rb, line 29 def count_records ids_reader.length end
delete(records)
click to toggle source
# File lib/active_fedora/filter/association.rb, line 13 def delete(records) extending_from.delete(records) end
ids_reader()
click to toggle source
Calls superclass method
# File lib/active_fedora/filter/association.rb, line 24 def ids_reader load_target super end
writer(records)
click to toggle source
@param [Array] records a list of records to replace the current association with @raise [ArgumentError] if one of the records doesn’t match the prescribed condition
# 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
Private Instance Methods
association_scope()
click to toggle source
We can’t create an association scope on here until we can figure a way to index/query the condition in Solr
# File lib/active_fedora/filter/association.rb, line 51 def association_scope nil end
existing_matching_records()
click to toggle source
# File lib/active_fedora/filter/association.rb, line 55 def existing_matching_records extending_from.reader.to_a.select do |r| validate_assertion(r) end end
extending_from()
click to toggle source
# File lib/active_fedora/filter/association.rb, line 61 def extending_from owner.association(options.fetch(:extending_from)) end
find_target()
click to toggle source
# File lib/active_fedora/filter/association.rb, line 45 def find_target existing_matching_records end
find_target?()
click to toggle source
# File lib/active_fedora/filter/association.rb, line 41 def find_target? true end
target()
click to toggle source
target should never be cached as part of this objects state, because extending_from.target could change and we want to reflect those changes
# File lib/active_fedora/filter/association.rb, line 37 def target find_target end
validate_assertion(record)
click to toggle source
# File lib/active_fedora/filter/association.rb, line 65 def validate_assertion(record) record.send(options.fetch(:condition)) end
validate_assertion!(record)
click to toggle source
# File lib/active_fedora/filter/association.rb, line 69 def validate_assertion!(record) raise ArgumentError, "#{record.class} with ID: #{record.id} was expected to #{options.fetch(:condition)}, but it was false" unless validate_assertion(record) end