Class: TraceViz::Context::Map
- Inherits:
-
Object
- Object
- TraceViz::Context::Map
- Defined in:
- lib/trace_viz/context/map.rb
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize ⇒ Map
constructor
A new instance of Map.
- #remove(*keys) ⇒ Object
- #replace(new_map) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Map
Returns a new instance of Map.
6 7 8 |
# File 'lib/trace_viz/context/map.rb', line 6 def initialize @context_map = {} end |
Instance Method Details
#fetch(key) ⇒ Object
14 15 16 17 18 |
# File 'lib/trace_viz/context/map.rb', line 14 def fetch(key) @context_map.fetch(key) rescue KeyError raise ContextError, "Context for key '#{key}' not found" end |
#remove(*keys) ⇒ Object
20 21 22 |
# File 'lib/trace_viz/context/map.rb', line 20 def remove(*keys) keys.each { |key| @context_map.delete(key) } end |
#replace(new_map) ⇒ Object
10 11 12 |
# File 'lib/trace_viz/context/map.rb', line 10 def replace(new_map) @context_map = new_map end |
#reset ⇒ Object
24 25 26 |
# File 'lib/trace_viz/context/map.rb', line 24 def reset @context_map.clear end |