class ActiveAny::Associations::HasManyAssociation

Public Instance Methods

empty?() click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 33
def empty?
  size.zero?
end
find_target() click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 45
def find_target
  scope.to_a
end
include?(record) click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 37
def include?(record)
  if record.is_a?(klass)
    target.include?(record)
  else
    false
  end
end
reader() click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 8
def reader
  # TODO: implement
  # reload if stale_target?

  @proxy ||= CollectionProxy.create(klass, self)
  @proxy.reset_scope
end
reset() click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 20
def reset
  super
  @target = []
end
size() click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 25
def size
  if !find_target? || loaded?
    target.size
  else
    scope.count
  end
end
writer(_records) click to toggle source
# File lib/active_any/associations/has_many_association.rb, line 16
def writer(_records)
  raise NotImplementedError.new, 'writer is unimplemented'
end