class ActiveState::StateValidator

Public Instance Methods

validate(record) click to toggle source
# 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, message|
    record.errors.add attribute, message
  end
end