class Rollbar::LazyStore
Attributes
Public Class Methods
Source
# File lib/rollbar/lazy_store.rb, line 6 def initialize(initial_data) initial_data ||= {} @raw = initial_data @loaded_data = {} end
Public Instance Methods
Source
# File lib/rollbar/lazy_store.rb, line 21 def ==(other) raw == if other.is_a?(self.class) other.raw else other end end
Source
# File lib/rollbar/lazy_store.rb, line 38 def []=(key, value) raw[key] = value loaded_data.delete(key) end
Source
# File lib/rollbar/lazy_store.rb, line 30 def clone self.class.new(raw.clone) end
With this version of clone we ensure that the loaded_data
is empty
Source
# File lib/rollbar/lazy_store.rb, line 44 def data raw.reduce({}) do |acc, (k, _)| acc[k] = self[k] acc end end
Source
# File lib/rollbar/lazy_store.rb, line 13 def eql?(other) if other.is_a?(self.class) raw.eql?(other.raw) else raw.eql?(other) end end
Private Instance Methods
Source
# File lib/rollbar/lazy_store.rb, line 64 def find_value(key) value = raw[key] value.respond_to?(:call) ? value.call : value end
Source
# File lib/rollbar/lazy_store.rb, line 54 def load_value(key) return loaded_data[key] if loaded_data.key?(key) return unless raw.key?(key) value = find_value(key) loaded_data[key] = value value end
Source
# File lib/rollbar/lazy_store.rb, line 69 def method_missing(method_sym, *args, &block) return raw.send(method_sym, *args, &block) if raw.respond_to?(method_sym) super end
Calls superclass method
Source
# File lib/rollbar/lazy_store.rb, line 75 def respond_to_missing?(method_sym, include_all) raw.respond_to?(method_sym, include_all) end