Class: Object

Inherits:
BasicObject
Defined in:
lib/sequel/extensions/sql_expr.rb,
lib/sequel/extensions/blank.rb

Overview

The sql_expr extension adds the sql_expr method to every object, which returns an wrapped object that works nicely with Sequel’s DSL by calling Sequel.expr:

1.sql_expr < :a     # 1 < a
false.sql_expr & :a # FALSE AND a
true.sql_expr | :a  # TRUE OR a
~nil.sql_expr       # NOT NULL
"a".sql_expr + "b"  # 'a' || 'b'

To load the extension:

Sequel.extension :sql_expr

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Objects are blank if they respond true to empty?

Returns:

  • (Boolean)


16
17
18
# File 'lib/sequel/extensions/blank.rb', line 16

def blank?
  respond_to?(:empty?) && empty?
end

#sql_exprObject

Return the object wrapper in an appropriate Sequel expression object.



17
18
19
# File 'lib/sequel/extensions/sql_expr.rb', line 17

def sql_expr
  Sequel.expr(self)
end