Class: Paradocs::Context
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #add_error(msg) ⇒ Object
- #errors ⇒ Object
-
#initialize(path = nil, top = Top.new, environment = {}, subschemes = {}) ⇒ Context
constructor
A new instance of Context.
- #sub(key) ⇒ Object
- #subschema(subschema_name) ⇒ Object
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
#environment ⇒ Object (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 |
#errors ⇒ Object
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 |