lib/rindle/collection.rb in rindle-0.1.1 vs lib/rindle/collection.rb in rindle-0.2.0
- old
+ new
@@ -99,21 +99,21 @@
end
# Adds an index or a document to the collection.
def add index
index = index.index if index.is_a?(Document)
- unless indices.include?(index)
- indices << obj.index
+ unless @indices.include?(index)
+ @indices << index
@documents = nil
end
end
# Removes an entry from this collection.
def remove index
index = index.index if index.is_a?(Document)
- if indices.include?(index)
- indices.delete index
+ if @indices.include?(index)
+ @indices.delete index
@documents = nil
end
end
# Sets the indices array and resets the documents memoized array
@@ -128,14 +128,14 @@
@documents ||= @indices.map { |i| Rindle.index[i] }
end
# Sets the array of `Document` objects.
def documents= documents
- indices = documents.map(&:index)
+ self.indices = documents.map(&:index)
@documents = documents
end
- # Returns true if the collection includes the given indec,
+ # Returns true if the collection includes the given index,
# `Document` or `Array`.
def include? obj
if obj.is_a?(Array)
obj.inject(true) { |acc, o| acc = acc and include?(o) }
elsif obj.is_a?(Document)