Module: Appsignal::Hooks::Helpers Private

Included in:
DelayedJobPlugin, SidekiqPlugin, Integrations::ResqueActiveJobPlugin
Defined in:
lib/appsignal/hooks.rb

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

#extract_value(object_or_hash, field, default_value = nil, convert_to_s = false) ⇒ Object

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.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/appsignal/hooks.rb', line 67

def extract_value(object_or_hash, field, default_value = nil, convert_to_s = false)
  value =
    if object_or_hash.respond_to?(:[])
      begin
        object_or_hash[field]
      rescue NameError
        nil
      end
    elsif object_or_hash.respond_to?(field)
      object_or_hash.send(field)
    end || default_value

  if convert_to_s
    value.to_s
  else
    value
  end
end

#string_or_inspect(string_or_other) ⇒ Object

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.



55
56
57
58
59
60
61
# File 'lib/appsignal/hooks.rb', line 55

def string_or_inspect(string_or_other)
  if string_or_other.is_a?(String)
    string_or_other
  else
    string_or_other.inspect
  end
end

#truncate(text) ⇒ Object

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.



63
64
65
# File 'lib/appsignal/hooks.rb', line 63

def truncate(text)
  text.size > 200 ? "#{text[0...197]}..." : text
end