Class: Influxer::Scoping::CurrentScope::ScopeRegistry

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::PerThreadRegistry
Defined in:
lib/influxer/metrics/scoping/current_scope.rb

Overview

:nodoc:

Constant Summary collapse

VALID_SCOPE_TYPES =
[:current_scope].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScopeRegistry

Returns a new instance of ScopeRegistry.



36
37
38
# File 'lib/influxer/metrics/scoping/current_scope.rb', line 36

def initialize
  @registry = Hash.new { |hash, key| hash[key] = {} }
end

Class Method Details

.instanceObject



28
29
30
# File 'lib/influxer/metrics/scoping/current_scope.rb', line 28

def instance
  ActiveSupport::IsolatedExecutionState[:influxer_scope_registry] ||= new
end

Instance Method Details

#set_value_for(scope_type, variable_name, value) ⇒ Object

Sets the value for a given scope_type and variable_name.



47
48
49
50
# File 'lib/influxer/metrics/scoping/current_scope.rb', line 47

def set_value_for(scope_type, variable_name, value)
  raise_invalid_scope_type!(scope_type)
  @registry[scope_type][variable_name] = value
end

#value_for(scope_type, variable_name) ⇒ Object

Obtains the value for a given scope_name and variable_name.



41
42
43
44
# File 'lib/influxer/metrics/scoping/current_scope.rb', line 41

def value_for(scope_type, variable_name)
  raise_invalid_scope_type!(scope_type)
  @registry[scope_type][variable_name]
end