Class: Grape::Util::LazyValueHash

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

Direct Known Subclasses

EndpointConfiguration

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(hash) ⇒ LazyValueHash

Returns a new instance of LazyValueHash.


80
81
82
83
84
85
86
# File 'lib/grape/util/lazy_value.rb', line 80

def initialize(hash)
  super
  @value_hash = {}.with_indifferent_access
  hash.each do |key, value|
    self[key] = value
  end
end

Instance Method Details

#evaluateObject


88
89
90
91
92
93
94
# File 'lib/grape/util/lazy_value.rb', line 88

def evaluate
  evaluated = {}.with_indifferent_access
  @value_hash.each do |key, value|
    evaluated[key] =  value.evaluate
  end
  evaluated
end