class ActiveFedora::Associations::HasManyAssociation
:nodoc:
def construct_query
def construct_query internal_uri = @owner.internal_uri escaped_uri = internal_uri.gsub(/(:)/, '\\:') @counter_query = @finder_query = "#{@reflection.options[:property]}_s:#{escaped_uri}" end
def count_records
If the collection is empty the target is set to an empty array and
account and delegates to +count_records+ if needed.
or not. The +size+ method is the one that takes the loaded flag into
That does not depend on whether the collection has already been loaded
Returns the number of records in this collection.
def count_records count = if loaded? @target.size else @reflection.klass.count(:conditions => @counter_query) # load_target # @target.size end # If there's nothing in the database and @target has no new records # we are certain the current target is an empty array. This is a # documented side-effect of the method that may avoid an extra SELECT. @target ||= [] and loaded if count == 0 return count end
def delete_records(records)
def delete_records(records) records.each do |r| r.remove_relationship(@reflection.options[:property], @owner) end end
def initialize(owner, reflection)
def initialize(owner, reflection) super end
def insert_record(record, force = false, validate = true)
def insert_record(record, force = false, validate = true) set_belongs_to_association_for(record) #force ? record.save! : record.save(:validate => validate) record.save end