Class: Sol::RuntimeModel::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/sol/runtime/context.rb

Constant Summary collapse

@@constants =

We store constants as class variable (class variables start with @@ and instance variables start with @ in Ruby) since they are globally accessible. If you want to implement namespacing of constants, you could store it in the instance of this class.

{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_self, current_class = current_self.runtime_class) ⇒ Context

Returns a new instance of Context.



14
15
16
17
18
19
20
21
22
# File 'lib/sol/runtime/context.rb', line 14

def initialize(current_self, current_class=current_self.runtime_class)

@locals = {}

@current_self = current_self

@current_class = current_class

end

Instance Attribute Details

#current_classObject (readonly)

Returns the value of attribute current_class.



7
8
9
# File 'lib/sol/runtime/context.rb', line 7

def current_class
  @current_class
end

#current_selfObject (readonly)

Returns the value of attribute current_self.



7
8
9
# File 'lib/sol/runtime/context.rb', line 7

def current_self
  @current_self
end

#localsObject (readonly)

Returns the value of attribute locals.



7
8
9
# File 'lib/sol/runtime/context.rb', line 7

def locals
  @locals
end

Instance Method Details

#[](name) ⇒ Object

Shortcuts to access constants, Runtime instead of Runtime.constants



26
27
28
29
30
# File 'lib/sol/runtime/context.rb', line 26

def [](name)

@@constants[name]

end

#[]=(name, value) ⇒ Object



32
33
34
35
36
# File 'lib/sol/runtime/context.rb', line 32

def []=(name, value)

@@constants[name] = value

end