Method: Array#case
- Defined in:
- lib/sequel/extensions/core_extensions.rb
#case(*args) ⇒ Object
Return a Sequel::SQL::CaseExpression with this array as the conditions and the given default value and expression.
[[{:a=>[2,3]}, 1]].case(0) # SQL: CASE WHEN a IN (2, 3) THEN 1 ELSE 0 END
[[:a, 1], [:b, 2]].case(:d, :c) # SQL: CASE c WHEN a THEN 1 WHEN b THEN 2 ELSE d END
35 36 37 |
# File 'lib/sequel/extensions/core_extensions.rb', line 35 def case(*args) ::Sequel::SQL::CaseExpression.new(self, *args) end |