Class: OverlapValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- OverlapValidator
- Defined in:
- lib/validates_overlap/overlap_validator.rb
Instance Attribute Summary collapse
-
#scoped_model ⇒ Object
Returns the value of attribute scoped_model.
-
#sql_conditions ⇒ Object
Returns the value of attribute sql_conditions.
-
#sql_values ⇒ Object
Returns the value of attribute sql_values.
Instance Method Summary collapse
-
#initialize(args) ⇒ OverlapValidator
constructor
A new instance of OverlapValidator.
- #validate(record) ⇒ Object
Constructor Details
#initialize(args) ⇒ OverlapValidator
10 11 12 13 |
# File 'lib/validates_overlap/overlap_validator.rb', line 10 def initialize(args) attributes_are_range(args[:attributes]) super end |
Instance Attribute Details
#scoped_model ⇒ Object
Returns the value of attribute scoped_model.
8 9 10 |
# File 'lib/validates_overlap/overlap_validator.rb', line 8 def scoped_model @scoped_model end |
#sql_conditions ⇒ Object
Returns the value of attribute sql_conditions.
6 7 8 |
# File 'lib/validates_overlap/overlap_validator.rb', line 6 def sql_conditions @sql_conditions end |
#sql_values ⇒ Object
Returns the value of attribute sql_values.
7 8 9 |
# File 'lib/validates_overlap/overlap_validator.rb', line 7 def sql_values @sql_values end |
Instance Method Details
#validate(record) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/validates_overlap/overlap_validator.rb', line 15 def validate(record) if self.find_crossed(record) if record.respond_to? attributes.first record.errors.add([:message_title] || attributes.first, [:message_content] || :overlap) else record.errors.add([:message_title] || :base, [:message_content] || :overlap) end end end |