Module: Lab42::DataClass::Proxy::Constraints::Maker
Instance Method Summary collapse
Instance Method Details
#make_constraint(constraint) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lab42/data_class/proxy/constraints/maker.rb', line 10 def make_constraint(constraint) case constraint when Proc, Method constraint when Symbol -> { _1.send(constraint) } when Array -> { _1.send(*constraint) } when Regexp -> { constraint.match?(_1) } when UnboundMethod -> { constraint.bind(_1).() } when Module -> { constraint === _1 } else _make_member_constraint(constraint) end end |