Class: BlockArray

Inherits:
Object
  • Object
show all
Defined in:
lib/active_document/database.rb

Overview

This allows us to support a block in find without changing the syntax.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ BlockArray

Returns a new instance of BlockArray.



169
170
171
172
# File 'lib/active_document/database.rb', line 169

def initialize(block)
  @block = block
  @size  = 0
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



173
174
175
# File 'lib/active_document/database.rb', line 173

def size
  @size
end

Instance Method Details

#<<(item) ⇒ Object



175
176
177
178
# File 'lib/active_document/database.rb', line 175

def <<(item)
  @size += 1
  @block.call(item)
end