Class: Groonga::RecordExpressionBuilder
- Inherits:
-
Object
- Object
- Groonga::RecordExpressionBuilder
show all
- Includes:
- ExpressionBuildable
- Defined in:
- lib/groonga/expression-builder.rb
Constant Summary
ExpressionBuildable::VALID_COLUMN_NAME_RE
Instance Attribute Summary
#allow_column, #allow_leading_not, #allow_pragma, #allow_update, #default_column, #query, #syntax, #table
Instance Method Summary
collapse
#&, #build, #|
Constructor Details
Returns a new instance of RecordExpressionBuilder.
446
447
448
449
450
|
# File 'lib/groonga/expression-builder.rb', line 446
def initialize(table, name)
super()
@table = table
@name = name
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
522
523
524
525
526
527
528
529
530
|
# File 'lib/groonga/expression-builder.rb', line 522
def method_missing(name, *args, &block)
return super if block
return super unless args.empty?
if VALID_COLUMN_NAME_RE =~ name.to_s
self[name]
else
super
end
end
|
Instance Method Details
452
453
454
455
456
457
458
459
460
|
# File 'lib/groonga/expression-builder.rb', line 452
def [](name)
column = @table.column(name)
if column.nil?
message = "unknown column <#{name.inspect}> " +
"for table <#{@table.inspect}>"
raise ArgumentError, message
end
column_expression_builder(column, name)
end
|
462
463
464
|
# File 'lib/groonga/expression-builder.rb', line 462
def id
self["_id"]
end
|
#index(name) ⇒ Object
496
497
498
499
500
501
502
503
504
505
506
|
# File 'lib/groonga/expression-builder.rb', line 496
def index(name)
object = @table.context[name]
if object.nil?
raise ArgumentError, "unknown index column: <#{name}>"
end
if object.range != @table
raise ArgumentError,
"different index column: <#{name}>: #{object.inspect}"
end
column_expression_builder(object, name)
end
|
466
467
468
|
# File 'lib/groonga/expression-builder.rb', line 466
def key
self["_key"]
end
|
#match(query, options_or_default_column = {}, &block) ⇒ Object
478
479
480
481
482
483
484
485
486
487
488
489
490
|
# File 'lib/groonga/expression-builder.rb', line 478
def match(query, options_or_default_column={}, &block)
if options_or_default_column.is_a?(String)
options = {:default_column => options_or_default_column}
else
options = options_or_default_column
end
options = options.dup
options[:syntax] ||= :query
if block_given? and options[:default_column].nil?
options[:default_column] = build_match_target(&block)
end
SubExpressionBuilder.new(query, options)
end
|
#match_target(&block) ⇒ Object
#n_sub_records ⇒ Object
474
475
476
|
# File 'lib/groonga/expression-builder.rb', line 474
def n_sub_records
self["_nsubrecs"]
end
|
470
471
472
|
# File 'lib/groonga/expression-builder.rb', line 470
def score
self["_score"]
end
|