Module: Hanami::Validations Private
- Defined in:
- lib/hanami/validations.rb,
lib/hanami/validations/form.rb,
lib/hanami/validations/version.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ClassMethods, Form Classes: Result
Constant Summary collapse
- VERSION =
The current hanami-validations version.
"2.1.0"
Class Method Summary collapse
- .gem_loader ⇒ Object private
- .included(klass) ⇒ Object private
Instance Method Summary collapse
-
#initialize(input) ⇒ Object
private
Initialize a new instance of a validator.
-
#to_h ⇒ Hash
private
Returns a Hash with the defined attributes as symbolized keys, and their relative values.
-
#validate ⇒ Hanami::Validations::Result
private
Validates the object.
Class Method Details
.gem_loader ⇒ 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.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hanami/validations.rb', line 15 def self.gem_loader @gem_loader ||= Zeitwerk::Loader.new.tap do |loader| root = File.("..", __dir__) loader.tag = "hanami-validations" loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-validations.rb") loader.push_dir(root) loader.ignore( "#{root}/hanami-validations.rb", "#{root}/hanami/validations/version.rb" ) end end |
.included(klass) ⇒ 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.
33 34 35 36 |
# File 'lib/hanami/validations.rb', line 33 def self.included(klass) super klass.extend(ClassMethods) end |
Instance Method Details
#initialize(input) ⇒ 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.
Initialize a new instance of a validator
82 83 84 |
# File 'lib/hanami/validations.rb', line 82 def initialize(input) @input = input end |
#to_h ⇒ Hash
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.
Returns a Hash with the defined attributes as symbolized keys, and their relative values.
105 106 107 |
# File 'lib/hanami/validations.rb', line 105 def to_h validate.to_h end |
#validate ⇒ Hanami::Validations::Result
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.
Validates the object.
92 93 94 95 96 |
# File 'lib/hanami/validations.rb', line 92 def validate Result.new( self.class._validator.call(@input) ) end |