Class: Lab42::BasicConstraints::Constraint
- Inherits:
-
Object
- Object
- Lab42::BasicConstraints::Constraint
- Defined in:
- lib/lab42/basic_constraints/constraint.rb
Instance Method Summary collapse
Instance Method Details
#call(value) ⇒ Object
9 10 11 12 |
# File 'lib/lab42/basic_constraints/constraint.rb', line 9 def call value return Result.ok if @constraint.(value) Result.error("#{_show value} is not a legal #{@name}", error: Lab42::BasicConstraints::ConstraintError) end |
#default ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/lab42/basic_constraints/constraint.rb', line 14 def default case @default when Proc @default.() else @default end end |
#set_default(value = nil, &blk) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/lab42/basic_constraints/constraint.rb', line 23 def set_default value=nil, &blk @default = if value value else blk end self end |