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.



160
161
162
163
# File 'lib/active_document/database.rb', line 160

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

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



164
165
166
# File 'lib/active_document/database.rb', line 164

def size
  @size
end

Instance Method Details

#<<(item) ⇒ Object



166
167
168
169
# File 'lib/active_document/database.rb', line 166

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