Class: Grape::Util::LazyValueArray

Inherits:
LazyValueEnumerable show all
Defined in:
lib/grape/util/lazy_value.rb

Instance Attribute Summary

Attributes inherited from LazyValue

#access_keys

Instance Method Summary collapse

Methods inherited from LazyValueEnumerable

#[], #[]=, #fetch

Methods inherited from LazyValue

#evaluate_from, #lazy?, #reached_by, #to_s

Constructor Details

#initialize(array) ⇒ LazyValueArray

Returns a new instance of LazyValueArray.


62
63
64
65
66
67
68
# File 'lib/grape/util/lazy_value.rb', line 62

def initialize(array)
  super
  @value_hash = []
  array.each_with_index do |value, index|
    self[index] = value
  end
end

Instance Method Details

#evaluateObject


70
71
72
73
74
75
76
# File 'lib/grape/util/lazy_value.rb', line 70

def evaluate
  evaluated = []
  @value_hash.each_with_index do |value, index|
    evaluated[index] = value.evaluate
  end
  evaluated
end