Class: Mcfly::Model::AssociationValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Mcfly::Model::AssociationValidator
- Defined in:
- lib/mcfly/has_mcfly.rb
Constant Summary collapse
- VALSET =
Set[nil, Float::INFINITY, 'infinity']
Instance Method Summary collapse
Instance Method Details
#validate(entry) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mcfly/has_mcfly.rb', line 39 def validate(entry) raise "need field option" unless [:field] field = [:field].to_sym value = entry.send(field) return if value.nil? unless VALSET.member?(value.obsoleted_dt) entry.errors[field] << "Obsoleted association value!" end end |