Class: Jaina::Parser::AST::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/jaina/parser/ast/context.rb

Overview

Since:

  • 0.1.0

Constant Summary collapse

Error =

Since:

  • 0.1.0

Class.new(StandardError)
UndefinedContextKeyError =

Since:

  • 0.1.0

Class.new(Error)

Instance Method Summary collapse

Constructor Details

#initialize(**initial_context) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • initial_context (Hash<Symbol,Any>)

Since:

  • 0.1.0



16
17
18
19
# File 'lib/jaina/parser/ast/context.rb', line 16

def initialize(**initial_context)
  @data = {}.merge!(initial_context)
  @access_lock = Mutex.new
end

Instance Method Details

#get(key) ⇒ Any

Parameters:

  • key (Any)

Returns:

  • (Any)

Since:

  • 0.1.0



36
37
38
# File 'lib/jaina/parser/ast/context.rb', line 36

def get(key)
  thread_safe { fetch(key) }
end

#keysArray<Any>

Returns:

  • (Array<Any>)

Since:

  • 0.1.0



44
45
46
# File 'lib/jaina/parser/ast/context.rb', line 44

def keys
  thread_safe { registered_data }
end

#set(key, value) ⇒ Any

Parameters:

  • key (Any)
  • value (Any)

Returns:

  • (Any)

Since:

  • 0.1.0



27
28
29
# File 'lib/jaina/parser/ast/context.rb', line 27

def set(key, value)
  thread_safe { apply(key, value) }
end