class ActiveFedora::Associations::FilterAssociation
def association_scope
We can't create an association scope on here until we can figure a way to
def association_scope nil end
def concat(records)
-
(ArgumentError)
- if one of the records doesn't match the prescribed condition
Parameters:
-
records
(Array
) -- a list of records to append to the current association
def concat(records) records.flatten.each { |r| validate_assertion!(r) } extending_from.concat(records) end
def count_records
def count_records ids_reader.length end
def existing_matching_records
def existing_matching_records extending_from.reader.to_a.select do |r| validate_assertion(r) end end
def extending_from
def extending_from owner.association(options.fetch(:extending_from)) end
def find_target
def find_target existing_matching_records end
def find_target?
def find_target? true end
def ids_reader
def ids_reader load_target super end
def target
target should never be cached as part of this objects state, because
def target find_target end
def validate_assertion(record)
def validate_assertion(record) record.send(options.fetch(:condition)) end
def validate_assertion!(record)
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
def writer(records)
-
(ArgumentError)
- if one of the records doesn't match the prescribed condition
Parameters:
-
records
(Array
) -- a list of records to replace the current association with
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