class StrongerParameters::EnumerationConstraint
Attributes
allowed[R]
Public Class Methods
new(*allowed)
click to toggle source
# File lib/stronger_parameters/constraints/enumeration_constraint.rb, line 8 def initialize(*allowed) @allowed = allowed end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
StrongerParameters::Constraint#==
# File lib/stronger_parameters/constraints/enumeration_constraint.rb, line 18 def ==(other) super && allowed == other.allowed end
value(v)
click to toggle source
# File lib/stronger_parameters/constraints/enumeration_constraint.rb, line 12 def value(v) return v if allowed.include?(v) InvalidValue.new(v, "must be one of these: #{allowed.to_sentence}") end