Class: Infold::Validation
- Inherits:
-
Object
- Object
- Infold::Validation
- Includes:
- ActiveModel::Model
- Defined in:
- lib/infold/property/validation.rb
Defined Under Namespace
Classes: ValidateCondition
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Instance Method Summary collapse
- #add_conditions(condition, options) ⇒ Object
- #has_presence? ⇒ Boolean
-
#initialize(field) ⇒ Validation
constructor
A new instance of Validation.
Constructor Details
#initialize(field) ⇒ Validation
Returns a new instance of Validation.
10 11 12 13 |
# File 'lib/infold/property/validation.rb', line 10 def initialize(field) @field = field self.conditions = [] end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
8 9 10 |
# File 'lib/infold/property/validation.rb', line 8 def conditions @conditions end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
7 8 9 |
# File 'lib/infold/property/validation.rb', line 7 def field @field end |
Instance Method Details
#add_conditions(condition, options) ⇒ Object
15 16 17 |
# File 'lib/infold/property/validation.rb', line 15 def add_conditions(condition, ) self.conditions << ValidateCondition.new(condition, ) end |
#has_presence? ⇒ Boolean
19 20 21 |
# File 'lib/infold/property/validation.rb', line 19 def has_presence? conditions.find { |c| c.condition == :presence } end |