Module: StackifyRubyAPM::NaivelyHashable Private

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#naively_hashable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


8
9
10
# File 'lib/stackify_apm/naively_hashable.rb', line 8

def naively_hashable?
  true
end

#to_hObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
# File 'lib/stackify_apm/naively_hashable.rb', line 12

def to_h
  instance_variables.each_with_object({}) do |name, h|
    key = name.to_s.delete('@').to_sym
    value = instance_variable_get(name)
    is_hashable =
      value.respond_to?(:naively_hashable?) && value.naively_hashable?

    h[key] = is_hashable ? value.to_h : value
  end
end