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, gem_spec: nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/action_reporter/base.rb', line 5
def self.class_accessor(class_name, gem_spec: nil)
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] ||= begin
if gem_spec
gem_name, version = gem_spec.scan(/([^(\s]+)\s*(?:\(([^)]+)\))?/).first
latest_spec = Gem.loaded_specs[gem_name]
version_satisfied = latest_spec && Gem::Requirement.new(version).satisfied_by?(latest_spec.version)
raise ActionReporter::Error.new("#{gem_spec} is not loaded") if !version_satisfied
end
Object.const_get(class_name)
end
end
end
|
Instance Method Details
#context ⇒ Object
46
47
|
# File 'lib/action_reporter/base.rb', line 46
def context(*)
end
|
#notify ⇒ Object
43
44
|
# File 'lib/action_reporter/base.rb', line 43
def notify(*)
end
|
#reset_context ⇒ Object
49
50
|
# File 'lib/action_reporter/base.rb', line 49
def reset_context
end
|
#resolve_check_in_id(identifier) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/action_reporter/base.rb', line 33
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 ArgumentError.new("Unknown check-in identifier: #{identifier.inspect}")
end
end
|
#transform_context(context) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/action_reporter/base.rb', line 23
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
|