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
457
458
459
460
461
|
# File 'lib/groonga/expression-builder.rb', line 457
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
533
534
535
536
537
538
539
540
541
|
# File 'lib/groonga/expression-builder.rb', line 533
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
463
464
465
466
467
468
469
470
471
|
# File 'lib/groonga/expression-builder.rb', line 463
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
|
473
474
475
|
# File 'lib/groonga/expression-builder.rb', line 473
def id
self["_id"]
end
|
#index(name) ⇒ Object
507
508
509
510
511
512
513
514
515
516
517
|
# File 'lib/groonga/expression-builder.rb', line 507
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
|
477
478
479
|
# File 'lib/groonga/expression-builder.rb', line 477
def key
self["_key"]
end
|
#match(query, options_or_default_column = {}, &block) ⇒ Object
489
490
491
492
493
494
495
496
497
498
499
500
501
|
# File 'lib/groonga/expression-builder.rb', line 489
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
503
504
505
|
# File 'lib/groonga/expression-builder.rb', line 503
def match_target(&block)
MatchTargetExpressionBuilder.new(build_match_target(&block))
end
|
#n_sub_records ⇒ Object
485
486
487
|
# File 'lib/groonga/expression-builder.rb', line 485
def n_sub_records
self["_nsubrecs"]
end
|
481
482
483
|
# File 'lib/groonga/expression-builder.rb', line 481
def score
self["_score"]
end
|