Class: StrongerParameters::BooleanConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- StrongerParameters::BooleanConstraint
- Defined in:
- lib/stronger_parameters/constraints/boolean_constraint.rb
Constant Summary collapse
- TRUE_VALUES =
[true, "true", "1", 1, "on"].freeze
- FALSE_VALUES =
[false, "false", "0", 0].freeze
Instance Method Summary collapse
Methods inherited from Constraint
#&, #==, #required, #required?, #|
Instance Method Details
#value(v) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/stronger_parameters/constraints/boolean_constraint.rb', line 10 def value(v) v = v.downcase if v.is_a? String return true if TRUE_VALUES.include?(v) return false if FALSE_VALUES.include?(v) InvalidValue.new(v, "must be either true or false") end |