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. This is best shown by example:
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'
Instance Method Summary (collapse)
-
- (Boolean) blank?
Objects are blank if they respond true to empty?.
-
- (Object) sql_expr
Return a copy of the object wrapped in a Sequel::SQL::Wrapper.
Instance Method Details
- (Boolean) blank?
Objects are blank if they respond true to empty?
12 13 14 |
# File 'lib/sequel/extensions/blank.rb', line 12 def blank? respond_to?(:empty?) && empty? end |
- (Object) sql_expr
Return a copy of the object wrapped in a Sequel::SQL::Wrapper. Allows easy use of the Object with Sequel's DSL. You'll probably have to make sure that Sequel knows how to literalize the object properly, though.
17 18 19 |
# File 'lib/sequel/extensions/sql_expr.rb', line 17 def sql_expr Sequel::SQL::Wrapper.new(self) end |