Module: ActiveModel::Validations::HelperMethods

Defined in:
lib/active_model/validations/helper_methods.rb

Instance Method Summary collapse

Instance Method Details

#validate_transitions(column, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_model/validations/helper_methods.rb', line 8

def validate_transitions(column, options = {})
  options = options.with_indifferent_access

  ValidTransitions::InputValidator.validate_options(options)

  transitions = options[:transitions]
  only_when   = options[:when]
  inclusive   = if options[:inclusive] == false
                  false
                else
                  true
                end
  validates_with ActiveModel::Validations::TransitionValidator, {
    column:            column,
    valid_transitions: transitions,
    when_validations:  only_when,
    inclusive:         inclusive
  }
end