class ParamsReady::Value::Constraint
Attributes
condition[R]
Public Class Methods
build(cond, *args, **opts, &block)
click to toggle source
# File lib/params_ready/value/constraint.rb, line 28 def self.build(cond, *args, **opts, &block) if block.nil? new cond, *args, **opts else new cond, block, *args, **opts end end
instance(cond, *args, **opts)
click to toggle source
# File lib/params_ready/value/constraint.rb, line 36 def self.instance(cond, *args, **opts) case cond when Range RangeConstraint.new(cond, *args, **opts) when Array, Set EnumConstraint.new(cond, *args, **opts) else raise ParamsReadyError, "Unknown constraint type: " + cond.class.name end end
new(cond)
click to toggle source
# File lib/params_ready/value/constraint.rb, line 21 def initialize(cond) @condition = cond.freeze freeze end
register(name)
click to toggle source
# File lib/params_ready/value/constraint.rb, line 15 def self.register(name) Constraint.register_constraint_type(name, self) end
Public Instance Methods
clamp?()
click to toggle source
# File lib/params_ready/value/constraint.rb, line 26 def clamp?; false; end
error_message()
click to toggle source
# File lib/params_ready/value/constraint.rb, line 51 def error_message "didn't pass validation" end
valid?(input)
click to toggle source
# File lib/params_ready/value/constraint.rb, line 47 def valid?(input) raise ParamsReadyError, 'This is an abstract class' end