class PoroValidator::Validators::BaseClass
Attributes
attribute[W]
Public Class Methods
new(attribute, options = {})
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 6 def initialize(attribute, options = {}) @attribute = attribute @options = options end
Public Instance Methods
__validate__(validator_context)
click to toggle source
@private
# File lib/poro_validator/validators/base_class.rb, line 62 def __validate__(validator_context) @context = validator_context @errors = validator_context.errors validate(attribute, value, options) end
attribute()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 15 def attribute @attribute end
context()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 23 def context @context end
errors()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 19 def errors @errors end
nested?()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 27 def nested? attribute.is_a?(::Array) end
options()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 11 def options @options end
validate(attribute, value, options)
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 31 def validate(attribute, value, options) raise ::PoroValidator::OverloadriddenRequired.new( "This method needs to be overloaded/overriden." ) end
value()
click to toggle source
# File lib/poro_validator/validators/base_class.rb, line 37 def value if entity_is_hash = context.entity.is_a?(::Hash) context.entity.extend(::PoroValidator::Utils::DeepFetch) end if nested? if entity_is_hash @value = context.entity.deep_fetch(*attribute.flatten) do nil end else @value = attribute.flatten.inject(context.entity, :public_send) end else if entity_is_hash @value = context.entity.deep_fetch(attribute) do nil end else @value = context.entity.public_send(attribute) end end end