Class: SmartCore::Validator Private
- Inherits:
-
Object
- Object
- SmartCore::Validator
- Extended by:
- DSL
- Defined in:
- lib/smart_core/validator.rb,
lib/smart_core/validator/dsl.rb,
lib/smart_core/validator/invoker.rb,
lib/smart_core/validator/error_set.rb,
lib/smart_core/validator/exceptions.rb,
lib/smart_core/validator/instance_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: Commands, DSL Classes: Attribute, AttributeSet, CommandSet, ErrorSet, InstanceBuilder, Invoker
Constant Summary collapse
- Error =
Class.new(SmartCore::Error)
- IncorrectErrorCodeError =
Class.new(Error)
- IncorrectAttributeNameError =
Class.new(Error)
Instance Attribute Summary collapse
- #__validation_errors__ ⇒ SmartCore::Validator::ErrorSet readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #__append_errors__(error_set) ⇒ void private
- #__attributes__ ⇒ Hash<Symbol,Object> private
- #errors ⇒ Array<Symbol>
- #initialize(&block) ⇒ void constructor
- #valid? ⇒ Boolean
Methods included from DSL
attribute, attributes, clear_commands, commands, extended, validate, validate_with
Constructor Details
#initialize(&block) ⇒ void
44 |
# File 'lib/smart_core/validator.rb', line 44 def initialize(*, **, &block); end |
Instance Attribute Details
#__validation_errors__ ⇒ SmartCore::Validator::ErrorSet (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/smart_core/validator.rb', line 38 def __validation_errors__ @__validation_errors__ end |
Class Method Details
.new(*arguments, **options, &block) ⇒ void
This method returns an undefined value.
27 28 29 30 31 |
# File 'lib/smart_core/validator.rb', line 27 def new(*arguments, **, &block) allocate.tap do |object| InstanceBuilder.call(object, self, arguments, , block) end end |
Instance Method Details
#__append_errors__(error_set) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
73 74 75 76 77 |
# File 'lib/smart_core/validator.rb', line 73 def __append_errors__(error_set) __thread_safe_access__ do __validation_errors__.concat(error_set) end end |
#__attributes__ ⇒ Hash<Symbol,Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 86 87 88 89 |
# File 'lib/smart_core/validator.rb', line 83 def __attributes__ __thread_safe_access__ do self.class.attributes.each_with_object({}) do |attribute, accumulator| accumulator[attribute.name] = instance_variable_get("@#{attribute.name}") end end end |
#errors ⇒ Array<Symbol>
62 63 64 65 66 |
# File 'lib/smart_core/validator.rb', line 62 def errors __thread_safe_access__ do __validation_errors__.codes end end |
#valid? ⇒ Boolean
50 51 52 53 54 55 56 |
# File 'lib/smart_core/validator.rb', line 50 def valid? __thread_safe_invokation__ do __validation_errors__.clear self.class.commands.each { |command| command.call(self) } __validation_errors__.empty? end end |