class Bindings::CacheBinding
An implementation of Bindings::Binding
that caches values once they've been retrieved.
Public Class Methods
new(delegate)
click to toggle source
Creates a new instance.
@param [Bindings::Binding] delegate the Binding
used to retrieve original values
# File lib/binding.rb, line 88 def initialize(delegate) @delegate = delegate @cache = {} end
Public Instance Methods
get_as_bytes(key)
click to toggle source
Returns the contents of a binding entry in its raw bytes form.
@param [String] key the key of the entry to retrieve @return [String] the contents of a binding entry if it exists @return [nil]
# File lib/binding.rb, line 98 def get_as_bytes(key) return @cache[key] if @cache.key?(key) v = @delegate.get_as_bytes(key) @cache[key] = v unless v.nil? v end
name()
click to toggle source
Returns the name of the binding
@return [String] the name of the binding
# File lib/binding.rb, line 110 def name @delegate.name end