class Cequel::Record::AssociationCollection
Collection
of records from a {Associations::ClassMethods#has_many has_many} association. Encapsulates and behaves like a {RecordSet}, but unlike a normal RecordSet
the loaded records are held in memory after they are loaded.
@see Associations::ClassMethods#has_many
@since 1.0.0
Public Instance Methods
count()
click to toggle source
@raise [DangerousQueryError] to prevent loading the entire record set
to be counted
# File lib/cequel/record/association_collection.rb, line 55 def count raise Cequel::Record::DangerousQueryError.new end
each(&block)
click to toggle source
@yield [Record] @return [void]
# File lib/cequel/record/association_collection.rb, line 20 def each(&block) target.each(&block) end
find(*keys)
click to toggle source
(see RecordSet#find
)
Calls superclass method
# File lib/cequel/record/association_collection.rb, line 27 def find(*keys) if block_given? then super else record_set.find(*keys) end end
first(*args)
click to toggle source
(see RecordSet#first
)
Calls superclass method
# File lib/cequel/record/association_collection.rb, line 45 def first(*args) if loaded? then super else record_set.first(*args) end end
loaded?()
click to toggle source
@return [Boolean] true if this collection's records are loaded in
memory
# File lib/cequel/record/association_collection.rb, line 65 def loaded? !!@target end
select(*columns)
click to toggle source
(see RecordSet#select
)
Calls superclass method
# File lib/cequel/record/association_collection.rb, line 36 def select(*columns) if block_given? then super else record_set.select(*columns) end end
Private Instance Methods
target()
click to toggle source
# File lib/cequel/record/association_collection.rb, line 73 def target @target ||= record_set.entries end