Class: FluentQuery::Queries::Abstract
- Inherits:
-
Object
- Object
- FluentQuery::Queries::Abstract
show all
- Defined in:
- lib/fluent-query/queries/abstract.rb
Overview
Represents and abstract query.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(connection) ⇒ Abstract
Returns a new instance of Abstract.
32
33
34
|
# File 'lib/fluent-query/queries/abstract.rb', line 32
def initialize(connection)
@connection = connection
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
19
20
21
|
# File 'lib/fluent-query/queries/abstract.rb', line 19
def connection
@connection
end
|
Instance Method Details
#all(*args) ⇒ Object
89
90
91
|
# File 'lib/fluent-query/queries/abstract.rb', line 89
def all(*args)
self.execute(*args).all
end
|
#assoc(*specification, &block) ⇒ Object
108
109
110
|
# File 'lib/fluent-query/queries/abstract.rb', line 108
def assoc(*specification, &block)
self.execute.assoc(*specification, &block)
end
|
#build(*args) ⇒ Object
Also known as:
build!
55
56
57
|
# File 'lib/fluent-query/queries/abstract.rb', line 55
def build(*args)
not_implemented
end
|
#do(*args) ⇒ Object
Also known as:
do!
77
78
79
|
# File 'lib/fluent-query/queries/abstract.rb', line 77
def do(*args)
@connection.do(self.build(*args))
end
|
#each(*args) ⇒ Object
126
127
128
129
130
|
# File 'lib/fluent-query/queries/abstract.rb', line 126
def each(*args)
self.execute(*args).each do |item|
yield item
end
end
|
#execute(*args) ⇒ Object
Also known as:
execute!
66
67
68
|
# File 'lib/fluent-query/queries/abstract.rb', line 66
def execute(*args)
@connection.execute(self.build(*args))
end
|
#find_all(*args, &block) ⇒ Object
Also known as:
filter
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/fluent-query/queries/abstract.rb', line 152
def find_all(*args, &block)
result = [ ]
self.each(*args) do |item|
if block.call(item) === true
result << block.call(item)
end
end
return result
end
|
#map(*args, &block) ⇒ Object
137
138
139
140
141
142
143
144
145
|
# File 'lib/fluent-query/queries/abstract.rb', line 137
def map(*args, &block)
result = [ ]
self.each(*args) do |item|
result << block.call(item)
end
return result
end
|
#one(*args) ⇒ Object
99
100
101
|
# File 'lib/fluent-query/queries/abstract.rb', line 99
def one(*args)
self.execute(*args).one
end
|
#processor ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/fluent-query/queries/abstract.rb', line 41
def processor
if not @processor
driver = @connection.driver
@processor = FluentQuery::Queries::Processor::new(driver)
end
return @processor
end
|
#single(*args) ⇒ Object
117
118
119
|
# File 'lib/fluent-query/queries/abstract.rb', line 117
def single(*args)
self.execute(*args).single
end
|