Class: Reform::Form::ActiveModel::Validations::Validator
- Inherits:
-
Object
- Object
- Reform::Form::ActiveModel::Validations::Validator
- Includes:
- Reform::Form::ActiveModel::Validations
- Defined in:
- lib/reform/form/active_model/validations.rb
Overview
Validators is the validatable object. On the class level, we define validations, on instance, it exposes #valid?.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(form, name) ⇒ Validator
constructor
A new instance of Validator.
- #method_missing(method_name, *args, &block) ⇒ Object
Methods included from Reform::Form::ActiveModel::Validations
#build_errors, included, #read_attribute_for_validation
Constructor Details
#initialize(form, name) ⇒ Validator
Returns a new instance of Validator.
63 64 65 66 |
# File 'lib/reform/form/active_model/validations.rb', line 63 def initialize(form, name) @form = form self.class.model_name = name # one of the many reasons why i will drop support for AM::V in 2.1. end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
68 69 70 |
# File 'lib/reform/form/active_model/validations.rb', line 68 def method_missing(method_name, *args, &block) @form.send(method_name, *args, &block) end |
Class Method Details
.clone ⇒ Object
58 59 60 |
# File 'lib/reform/form/active_model/validations.rb', line 58 def clone Class.new(self) end |
.model_name ⇒ Object
50 51 52 |
# File 'lib/reform/form/active_model/validations.rb', line 50 def model_name @_active_model_sucks || ActiveModel::Name.new(Reform::Form, nil, "Reform::Form") end |
.model_name=(name) ⇒ Object
54 55 56 |
# File 'lib/reform/form/active_model/validations.rb', line 54 def model_name=(name) @_active_model_sucks = name end |