Class: Groonga::ExpressionBuildable::ColumnValueExpressionBuilder
Instance Method Summary
collapse
#&, #|
Constructor Details
Returns a new instance of ColumnValueExpressionBuilder.
154
155
156
157
158
159
160
161
|
# File 'lib/groonga/expression-builder.rb', line 154
def initialize(column, options={})
super()
@table = options[:table] || column.table
@column = column
@column_name = options[:column_name] || @column.local_name
@range = options[:range] || @column.range
@name = options[:name]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/groonga/expression-builder.rb', line 282
def method_missing(name, *args, &block)
return super if block
if args.empty? and VALID_COLUMN_NAME_RE =~ name.to_s
accessor_name = "#{@column_name}.#{name}"
accessor = @table.column(accessor_name)
if accessor
return self.class.new(accessor,
:table => @table,
:column_name => accessor_name)
end
end
object = @table.context[name]
if callable_object?(object)
return CallExpressionBuilder.new(object, self, *args)
end
super
end
|
Instance Method Details
227
228
229
|
# File 'lib/groonga/expression-builder.rb', line 227
def %(other)
ModExpressionBuilder.new(self, normalize(other))
end
|
219
220
221
|
# File 'lib/groonga/expression-builder.rb', line 219
def *(other)
StarExpressionBuilder.new(self, normalize(other))
end
|
211
212
213
|
# File 'lib/groonga/expression-builder.rb', line 211
def +(other)
PlusExpressionBuilder.new(self, normalize(other))
end
|
215
216
217
|
# File 'lib/groonga/expression-builder.rb', line 215
def -(other)
MinusExpressionBuilder.new(self, normalize(other))
end
|
223
224
225
|
# File 'lib/groonga/expression-builder.rb', line 223
def /(other)
SlashExpressionBuilder.new(self, normalize(other))
end
|
195
196
197
|
# File 'lib/groonga/expression-builder.rb', line 195
def <(other)
LessExpressionBuilder.new(self, normalize(other))
end
|
#=~(other) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/groonga/expression-builder.rb', line 181
def =~(other)
if other.nil?
full_column_name = "#{@table.name}.#{@column_name}"
raise ArgumentError,
"match word should not be nil: #{full_column_name}"
end
if other.is_a?(Regexp)
RegexpExpressionBuilder.new(self, normalize(other.source))
else
MatchExpressionBuilder.new(self, normalize(other))
end
end
|
#build(expression, variable) ⇒ Object
163
164
165
166
167
168
169
170
171
|
# File 'lib/groonga/expression-builder.rb', line 163
def build(expression, variable)
expression.append_object(variable)
if @column.is_a?(String)
expression.append_constant(@column)
else
expression.append_object(@column)
end
expression.append_operation(Groonga::Operation::GET_VALUE, 2)
end
|
#match(query, options = {}) ⇒ Object
231
232
233
234
235
236
|
# File 'lib/groonga/expression-builder.rb', line 231
def match(query, options={})
options = options.dup
options[:syntax] ||= :query
options[:default_column] = @column_name
SubExpressionBuilder.new(query, options)
end
|
#prefix_search(other) ⇒ Object
#similar_search(other) ⇒ Object
#suffix_search(other) ⇒ Object
250
251
252
253
254
255
256
257
258
|
# File 'lib/groonga/expression-builder.rb', line 250
def (other)
if @column_name == "_key"
TermExtractExpressionBuilder.new(self, normalize(other))
else
message = "term extraction supports _key column only: " +
"<#{@column_name}>"
raise ArgumentError, message
end
end
|