Class: ActiveGraph::Node::Scope::ScopeRegistry
- Inherits:
-
Object
- Object
- ActiveGraph::Node::Scope::ScopeRegistry
- Extended by:
- ActiveSupport::PerThreadRegistry
- Defined in:
- lib/active_graph/node/scope.rb
Overview
Constant Summary collapse
- VALID_SCOPE_TYPES =
[:current_scope, :ignore_default_scope]
Instance Method Summary collapse
-
#initialize ⇒ ScopeRegistry
constructor
A new instance of ScopeRegistry.
-
#set_value_for(scope_type, variable_name, value) ⇒ Object
Sets the
value
for a givenscope_type
andvariable_name
. -
#value_for(scope_type, variable_name) ⇒ Object
Obtains the value for a given
scope_name
andvariable_name
.
Constructor Details
#initialize ⇒ ScopeRegistry
Returns a new instance of ScopeRegistry.
151 152 153 |
# File 'lib/active_graph/node/scope.rb', line 151 def initialize @registry = Hash.new { |hash, key| hash[key] = {} } end |
Instance Method Details
#set_value_for(scope_type, variable_name, value) ⇒ Object
Sets the value
for a given scope_type
and variable_name
.
162 163 164 165 |
# File 'lib/active_graph/node/scope.rb', line 162 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
.
156 157 158 159 |
# File 'lib/active_graph/node/scope.rb', line 156 def value_for(scope_type, variable_name) raise_invalid_scope_type!(scope_type) @registry[scope_type][variable_name] end |