Class: Judge::Validator
- Inherits:
-
Object
- Object
- Judge::Validator
- Defined in:
- lib/judge/validator.rb
Constant Summary collapse
- REJECTED_OPTIONS =
[:if, :on, :unless, :tokenizer, :scope, :case_sensitive, :judge]
Instance Attribute Summary collapse
-
#active_model_validator ⇒ Object
readonly
Returns the value of attribute active_model_validator.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original_value ⇒ Object
readonly
Returns the value of attribute original_value.
Instance Method Summary collapse
-
#initialize(object, method, amv) ⇒ Validator
constructor
A new instance of Validator.
- #to_hash ⇒ Object
Constructor Details
#initialize(object, method, amv) ⇒ Validator
9 10 11 12 13 14 15 |
# File 'lib/judge/validator.rb', line 9 def initialize(object, method, amv) @kind = amv.kind @options = amv..reject { |key| REJECTED_OPTIONS.include?(key) } @method = method @messages = Judge::MessageCollection.new(object, method, amv) @original_value = object.send(method) end |
Instance Attribute Details
#active_model_validator ⇒ Object (readonly)
Returns the value of attribute active_model_validator.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def active_model_validator @active_model_validator end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def kind @kind end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def @messages end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def @options end |
#original_value ⇒ Object (readonly)
Returns the value of attribute original_value.
5 6 7 |
# File 'lib/judge/validator.rb', line 5 def original_value @original_value end |
Instance Method Details
#to_hash ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/judge/validator.rb', line 17 def to_hash params = { :kind => kind, :options => , :messages => .to_hash } params[:original_value] = original_value if kind == :uniqueness params end |