Class: ActiveModel::Validations::StateHistoryEntryValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- ActiveModel::Validations::StateHistoryEntryValidator
- Defined in:
- lib/active_model/validations/state_history_entry_validator.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StateHistoryEntryValidator
constructor
A new instance of StateHistoryEntryValidator.
- #validate(record) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ StateHistoryEntryValidator
Returns a new instance of StateHistoryEntryValidator.
5 6 7 8 9 10 11 |
# File 'lib/active_model/validations/state_history_entry_validator.rb', line 5 def initialize( = {}) super @start = [:start] || :start @end = [:end] || :end @allow = [:allow] || [] end |
Instance Method Details
#validate(record) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/active_model/validations/state_history_entry_validator.rb', line 13 def validate(record) non_zero?(record) unless @allow.include? :zero_duration start_before_end?(record) unless @allow.include? :end_before_start return end |