Class: Hash

Inherits:
Object show all
Defined in:
lib/sequel/core_sql.rb,
lib/sequel/deprecated.rb

Instance Method Summary collapse

Instance Method Details

#&(ce) ⇒ Object

Return a Sequel::SQL::BooleanExpression created from this hash, matching all of the conditions in this hash and the condition specified by the given argument.



80
81
82
# File 'lib/sequel/core_sql.rb', line 80

def &(ce)
  ::Sequel::SQL::BooleanExpression.new(:AND, self, ce)
end

#case(default, expression = nil) ⇒ Object

Return a Sequel::SQL::CaseExpression with this hash as the conditions and the given default value. Note that the order of the conditions will be arbitrary, so all conditions should be orthogonal.



100
101
102
# File 'lib/sequel/core_sql.rb', line 100

def case(default, expression = nil)
  ::Sequel::SQL::CaseExpression.new(to_a, default, expression)
end

#sql_exprObject

Return a Sequel::SQL::BooleanExpression created from this hash, matching all of the conditions.



106
107
108
# File 'lib/sequel/core_sql.rb', line 106

def sql_expr
  ::Sequel::SQL::BooleanExpression.from_value_pairs(self)
end

#sql_negateObject

Return a Sequel::SQL::BooleanExpression created from this hash, matching none of the conditions.



112
113
114
# File 'lib/sequel/core_sql.rb', line 112

def sql_negate
  ::Sequel::SQL::BooleanExpression.from_value_pairs(self, :AND, true)
end

#sql_orObject

Return a Sequel::SQL::BooleanExpression created from this hash, matching any of the conditions.



118
119
120
# File 'lib/sequel/core_sql.rb', line 118

def sql_or
  ::Sequel::SQL::BooleanExpression.from_value_pairs(self, :OR)
end

#|(ce) ⇒ Object

Return a Sequel::SQL::BooleanExpression created from this hash, matching all of the conditions in this hash or the condition specified by the given argument.



87
88
89
# File 'lib/sequel/core_sql.rb', line 87

def |(ce)
  ::Sequel::SQL::BooleanExpression.new(:OR, self, ce)
end

#~Object

Return a Sequel::SQL::BooleanExpression created from this hash, not matching any of the conditions.



93
94
95
# File 'lib/sequel/core_sql.rb', line 93

def ~
  ::Sequel::SQL::BooleanExpression.from_value_pairs(self, :OR, true)
end