Class: Errapi::ObjectValidator::ContextProxy
- Inherits:
-
Object
- Object
- Errapi::ObjectValidator::ContextProxy
- Defined in:
- lib/errapi/object_validator.rb
Instance Attribute Summary collapse
-
#current_location ⇒ Object
Returns the value of attribute current_location.
Instance Method Summary collapse
- #add_error(options = {}, &block) ⇒ Object
- #errors?(criteria = {}, &block) ⇒ Boolean
-
#initialize(context, validator, location) ⇒ ContextProxy
constructor
A new instance of ContextProxy.
-
#with_error_options(error_options = {}, &block) ⇒ Object
TODO: override errors? to support matching relative error locations.
Constructor Details
#initialize(context, validator, location) ⇒ ContextProxy
Returns a new instance of ContextProxy.
193 194 195 196 197 198 |
# File 'lib/errapi/object_validator.rb', line 193 def initialize context, validator, location @context = context @validator = validator @current_location = location @error_options = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
225 226 227 |
# File 'lib/errapi/object_validator.rb', line 225 def method_missing name, *args, &block @context.send name, *args, &block end |
Instance Attribute Details
#current_location ⇒ Object
Returns the value of attribute current_location.
191 192 193 |
# File 'lib/errapi/object_validator.rb', line 191 def current_location @current_location end |
Instance Method Details
#add_error(options = {}, &block) ⇒ Object
200 201 202 |
# File 'lib/errapi/object_validator.rb', line 200 def add_error = {}, &block @context.add_error @error_options.merge(), &block end |
#errors?(criteria = {}, &block) ⇒ Boolean
204 205 206 207 208 209 210 211 212 |
# File 'lib/errapi/object_validator.rb', line 204 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 = {}, &block) ⇒ Object
TODO: override errors? to support matching relative error locations
216 217 218 219 220 221 |
# File 'lib/errapi/object_validator.rb', line 216 def = {}, &block = @error_options @error_options = block.call @error_options = end |