Class: ActiveState::StateValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- ActiveState::StateValidator
- Defined in:
- lib/active_state/state_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/active_state/state_validator.rb', line 3 def validate(record) state = record.state unless state.respond_to? :valid? raise NoMethodError, "State object #{state.inspect} does not respond to :valid?" end return if state.valid? state.errors.each do |attribute, | record.errors.add attribute, end end |