Class: Paradocs::Context

Inherits:
Object show all
Defined in:
lib/paradocs/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, top = Top.new, environment = {}, subschemes = {}) ⇒ Context

Returns a new instance of Context.


17
18
19
20
21
22
# File 'lib/paradocs/context.rb', line 17

def initialize(path=nil, top=Top.new, environment={}, subschemes={})
  @top = top
  @path = Array(path).compact
  @environment = environment
  @subschemes = subschemes
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.


16
17
18
# File 'lib/paradocs/context.rb', line 16

def environment
  @environment
end

Instance Method Details

#add_error(msg) ⇒ Object


35
36
37
# File 'lib/paradocs/context.rb', line 35

def add_error(msg)
  top.add_error(string_path, msg)
end

#errorsObject


31
32
33
# File 'lib/paradocs/context.rb', line 31

def errors
  top.errors
end

#sub(key) ⇒ Object


39
40
41
# File 'lib/paradocs/context.rb', line 39

def sub(key)
  self.class.new(path + [key], top, environment, @subschemes)
end

#subschema(subschema_name) ⇒ Object


24
25
26
27
28
29
# File 'lib/paradocs/context.rb', line 24

def subschema(subschema_name)
  subschema = @subschemes[subschema_name]
  return unless subschema
  @subschemes.merge!(subschema.subschemes)
  subschema
end