Class: Budgie::AutoArray

Inherits:
Array
  • Object
show all
Defined in:
lib/budgie/auto_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AutoArray

Returns a new instance of AutoArray.



5
6
7
8
# File 'lib/budgie/auto_array.rb', line 5

def initialize(&block)
  @block = block
  super
end

Instance Method Details

#[](index) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/budgie/auto_array.rb', line 10

def [](index)
  value = super

  if value.nil?
    populate index
    super
  else
    value
  end
end