Class: StructuredReader::JSONReader::ValidatorContext
- Inherits:
-
Object
- Object
- StructuredReader::JSONReader::ValidatorContext
- Defined in:
- lib/structured_reader.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #accept(fragment) ⇒ Object
- #flunk(fragment, reason) ⇒ Object
-
#initialize(where = "", errors = []) ⇒ ValidatorContext
constructor
A new instance of ValidatorContext.
- #open(&blk) ⇒ Object
- #push(path) {|self.class.new(@where + path, @errors)| ... } ⇒ Object
Constructor Details
#initialize(where = "", errors = []) ⇒ ValidatorContext
Returns a new instance of ValidatorContext.
353 354 355 356 |
# File 'lib/structured_reader.rb', line 353 def initialize(where = "", errors = []) @where = where.dup.freeze @errors = errors end |
Instance Method Details
#accept(fragment) ⇒ Object
363 364 365 |
# File 'lib/structured_reader.rb', line 363 def accept(fragment) fragment end |
#flunk(fragment, reason) ⇒ Object
367 368 369 |
# File 'lib/structured_reader.rb', line 367 def flunk(fragment, reason) @errors << [@where, reason] end |
#open(&blk) ⇒ Object
358 359 360 361 |
# File 'lib/structured_reader.rb', line 358 def open(&blk) result = blk.call(self) Result.new(@errors.any? ? nil : result, @errors) end |
#push(path) {|self.class.new(@where + path, @errors)| ... } ⇒ Object
371 372 373 |
# File 'lib/structured_reader.rb', line 371 def push(path) yield self.class.new(@where + path, @errors) end |