Method: Hash#case

Defined in:
lib/sequel/extensions/core_extensions.rb

#case(*args) ⇒ Object

Return a Sequel::SQL::CaseExpression with this hash as the conditions and the given default value.

{{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


133
134
135
# File 'lib/sequel/extensions/core_extensions.rb', line 133

def case(*args)
  ::Sequel::SQL::CaseExpression.new(to_a, *args)
end