Class: ActionReporter::Base
- Inherits:
-
Object
- Object
- ActionReporter::Base
show all
- Defined in:
- lib/action_reporter/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.class_accessor(class_name) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/action_reporter/base.rb', line 5
def self.class_accessor(class_name)
method_name = class_name.gsub("::", "_").downcase + "_class"
define_method(method_name) do
raise ActionReporter::Error.new("#{class_name} is not defined") unless Object.const_defined?(class_name)
@class_cache ||= {}
@class_cache[class_name] ||= Object.const_get(class_name)
end
end
|
Instance Method Details
#context ⇒ Object
50
51
|
# File 'lib/action_reporter/base.rb', line 50
def context(*)
end
|
#merge_context_updates(current, updates) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/action_reporter/base.rb', line 27
def merge_context_updates(current, updates)
transformed = transform_context(updates)
keys_to_remove = transformed.each_with_object([]) do |(key, value), removals|
removals << key if value.nil?
end
current.merge(transformed).except(*keys_to_remove)
end
|
#notify ⇒ Object
47
48
|
# File 'lib/action_reporter/base.rb', line 47
def notify(*)
end
|
#reset_context ⇒ Object
53
54
|
# File 'lib/action_reporter/base.rb', line 53
def reset_context
end
|
#resolve_check_in_id(identifier) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/action_reporter/base.rb', line 35
def resolve_check_in_id(identifier)
if identifier.respond_to?(:reporter_check_in)
identifier.reporter_check_in
elsif identifier.respond_to?(:to_s)
identifier.to_s
else
raise ActionReporter::Error.new(
"Unknown check-in identifier (#{identifier.class}, object_id=#{identifier.object_id})"
)
end
end
|
#resolve_user_id(user) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/action_reporter/base.rb', line 62
def resolve_user_id(user)
resolver = ActionReporter.user_id_resolver
if resolver.respond_to?(:call)
resolver.call(user)
else
default_resolve_user_id(user)
end
end
|
#transaction_id=(transaction_id) ⇒ Object
56
57
|
# File 'lib/action_reporter/base.rb', line 56
def transaction_id=(transaction_id)
end
|
#transaction_name=(transaction_name) ⇒ Object
59
60
|
# File 'lib/action_reporter/base.rb', line 59
def transaction_name=(transaction_name)
end
|
#transform_context(context) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/action_reporter/base.rb', line 17
def transform_context(context)
ActionReporter::Utils.deep_transform_values(context) do |value|
if value.respond_to?(:to_global_id)
value.to_global_id.to_s
else
value
end
end
end
|