class ApiBomb::LambdaHash
values can respond to call making them dynamic
Public Class Methods
hasharize(hash)
click to toggle source
# File lib/api_bomb/lambda_hash.rb, line 3 def self.hasharize(hash) hash_call = self.new(hash) h = {} hash_call.each do |v, k| h[v] = hash_call[v] if h[v].is_a? self h[v] = self.hasharize(h[v]) end end return h end
Public Instance Methods
[](key)
click to toggle source
# File lib/api_bomb/lambda_hash.rb, line 32 def [](key) value = self.__getobj__[key] value = value.call if value.respond_to? :call value = self.class.new(value) if value.is_a? Hash return value end
is_lambda?()
click to toggle source
# File lib/api_bomb/lambda_hash.rb, line 16 def is_lambda? return false if self.blank? self.each do |k,v| if self[k].is_a? self.class return self[k].is_lambda? else if self.real[k].respond_to? :call return true else return false end end end end
real()
click to toggle source
# File lib/api_bomb/lambda_hash.rb, line 40 def real self.__getobj__ end