class Errapi::ObjectValidator::ContextProxy

Attributes

current_location[RW]

Public Class Methods

new(context, validator, location) click to toggle source
# File lib/errapi/object_validator.rb, line 202
def initialize context, validator, location
  @context = context
  @validator = validator
  @current_location = location
  @error_options = {}
end

Public Instance Methods

add_error(options = {}) click to toggle source
# File lib/errapi/object_validator.rb, line 209
def add_error options = {}, &block
  @context.add_error @error_options.merge(options), &block
end
errors?(criteria = {}) click to toggle source
# File lib/errapi/object_validator.rb, line 213
def errors? criteria = {}, &block

  if criteria[:location].kind_of? RelativeLocation
    criteria = criteria.dup
    criteria[:location] = @current_location.relative criteria[:location].location
  end

  @context.errors? criteria, &block
end
with_error_options(error_options = {}) click to toggle source

TODO: override errors? to support matching relative error locations

# File lib/errapi/object_validator.rb, line 225
def with_error_options error_options = {}, &block
  previous_error_options = @error_options
  @error_options = error_options
  block.call
  @error_options = previous_error_options
end

Protected Instance Methods

method_missing(name, *args, &block) click to toggle source
# File lib/errapi/object_validator.rb, line 234
def method_missing name, *args, &block
  @context.send name, *args, &block
end