Class: Flounder::Expression::Expr
- Inherits:
-
Object
- Object
- Flounder::Expression::Expr
show all
- Includes:
- SymbolExtensions
- Defined in:
- lib/flounder/expression.rb
Instance Method Summary
collapse
Constructor Details
#initialize(domain) ⇒ Expr
Returns a new instance of Expr.
4
5
6
|
# File 'lib/flounder/expression.rb', line 4
def initialize domain
@domain = domain
end
|
Instance Method Details
#&(expr) ⇒ Object
17
18
19
|
# File 'lib/flounder/expression.rb', line 17
def & expr
BinaryOp.new(@domain, 'AND', self, expr)
end
|
#as(name) ⇒ Object
8
9
10
|
# File 'lib/flounder/expression.rb', line 8
def as name
Named.new(@domain, name, self)
end
|
#cast(type) ⇒ Object
11
12
13
|
# File 'lib/flounder/expression.rb', line 11
def cast type
Cast.new(@domain, type, self)
end
|
#db_quote(something) ⇒ Object
36
37
38
39
40
|
# File 'lib/flounder/expression.rb', line 36
def db_quote something
@domain.with_connection do |conn|
conn.quote(something)
end
end
|
#eval(argument) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/flounder/expression.rb', line 21
def eval argument
case argument
when String, Symbol
db_quote(argument.to_s)
when Fixnum
argument
when Expr
argument.to_sql
when Flounder::Field
argument.fully_qualified_name
else
db_quote(argument)
end
end
|
45
46
47
|
# File 'lib/flounder/expression.rb', line 45
def to_immediate
Flounder::Immediate.new(to_sql)
end
|
#to_sql ⇒ Object
42
43
44
|
# File 'lib/flounder/expression.rb', line 42
def to_sql
raise NotImplementedError
end
|
#|(expr) ⇒ Object
14
15
16
|
# File 'lib/flounder/expression.rb', line 14
def | expr
BinaryOp.new(@domain, 'OR', self, expr)
end
|