Class: Validatable::ValidationBase
- Inherits:
-
Object
- Object
- Validatable::ValidationBase
- Defined in:
- lib/validatable/validations/validation_base.rb
Overview
:nodoc:
Direct Known Subclasses
ValidatesAcceptanceOf, ValidatesAssociated, ValidatesConfirmationOf, ValidatesEach, ValidatesExclusionOf, ValidatesFormatOf, ValidatesInclusionOf, ValidatesLengthOf, ValidatesNumericalityOf, ValidatesPresenceOf, ValidatesTrueFor
Instance Attribute Summary collapse
-
#after_validate ⇒ Object
Returns the value of attribute after_validate.
-
#allow_blank ⇒ Object
Returns the value of attribute allow_blank.
-
#allow_nil ⇒ Object
Returns the value of attribute allow_nil.
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#if ⇒ Object
Returns the value of attribute if.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#message ⇒ Object
writeonly
Sets the attribute message.
Instance Method Summary collapse
-
#initialize(klass, attribute, options = {}) ⇒ ValidationBase
constructor
A new instance of ValidationBase.
- #validate(instance) ⇒ Object
Constructor Details
#initialize(klass, attribute, options = {}) ⇒ ValidationBase
Returns a new instance of ValidationBase.
6 7 8 9 10 |
# File 'lib/validatable/validations/validation_base.rb', line 6 def initialize(klass, attribute, ={}) self.klass = klass .each{|k, v| self.send :"#{k}=", v} self.attribute = attribute end |
Instance Attribute Details
#after_validate ⇒ Object
Returns the value of attribute after_validate.
3 4 5 |
# File 'lib/validatable/validations/validation_base.rb', line 3 def after_validate @after_validate end |
#allow_blank ⇒ Object
Returns the value of attribute allow_blank.
3 4 5 |
# File 'lib/validatable/validations/validation_base.rb', line 3 def allow_blank @allow_blank end |
#allow_nil ⇒ Object
Returns the value of attribute allow_nil.
3 4 5 |
# File 'lib/validatable/validations/validation_base.rb', line 3 def allow_nil @allow_nil end |
#attribute ⇒ Object
Returns the value of attribute attribute.
4 5 6 |
# File 'lib/validatable/validations/validation_base.rb', line 4 def attribute @attribute end |
#if ⇒ Object
Returns the value of attribute if.
3 4 5 |
# File 'lib/validatable/validations/validation_base.rb', line 3 def if @if end |
#klass ⇒ Object
Returns the value of attribute klass.
4 5 6 |
# File 'lib/validatable/validations/validation_base.rb', line 4 def klass @klass end |
#message=(value) ⇒ Object
Sets the attribute message
3 4 5 |
# File 'lib/validatable/validations/validation_base.rb', line 3 def (value) @message = value end |
Instance Method Details
#validate(instance) ⇒ Object
12 13 14 15 16 |
# File 'lib/validatable/validations/validation_base.rb', line 12 def validate instance if should_validate?(instance) and !valid?(instance) instance.errors.add attribute, (self) end end |