class SentryApi::ObjectifiedHash
Converts hashes to the objects.
Public Class Methods
new(hash)
click to toggle source
Creates a new ObjectifiedHash
object.
# File lib/sentry-api/objectified_hash.rb, line 5 def initialize(hash) @hash = hash @data = hash.inject({}) do |data, (key, value)| value = ObjectifiedHash.new(value) if value.is_a? Hash data[key.to_s] = value data end end
Public Instance Methods
inspect()
click to toggle source
@return [String] Formatted string with the class name, object id and original hash.
# File lib/sentry-api/objectified_hash.rb, line 22 def inspect "#<#{self.class}:#{object_id} {hash: #{@hash.inspect}}" end
method_missing(key)
click to toggle source
Delegate to ObjectifiedHash
.
# File lib/sentry-api/objectified_hash.rb, line 27 def method_missing(key) @data.key?(key.to_s) ? @data[key.to_s] : nil end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/sentry-api/objectified_hash.rb, line 31 def respond_to_missing?(method_name, include_private = false) @hash.keys.map(&:to_sym).include?(method_name.to_sym) || super end
to_hash()
click to toggle source
@return [Hash] The original hash.
# File lib/sentry-api/objectified_hash.rb, line 15 def to_hash @hash end
Also aliased as: to_h