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.



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

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

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#<<(item) ⇒ Object



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

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