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.
444
445
446
447
448
|
# File 'lib/groonga/expression-builder.rb', line 444
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
520
521
522
523
524
525
526
527
528
|
# File 'lib/groonga/expression-builder.rb', line 520
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
450
451
452
453
454
455
456
457
458
|
# File 'lib/groonga/expression-builder.rb', line 450
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
|
460
461
462
|
# File 'lib/groonga/expression-builder.rb', line 460
def id
self["_id"]
end
|
#index(name) ⇒ Object
494
495
496
497
498
499
500
501
502
503
504
|
# File 'lib/groonga/expression-builder.rb', line 494
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
|
464
465
466
|
# File 'lib/groonga/expression-builder.rb', line 464
def key
self["_key"]
end
|
#match(query, options_or_default_column = {}, &block) ⇒ Object
476
477
478
479
480
481
482
483
484
485
486
487
488
|
# File 'lib/groonga/expression-builder.rb', line 476
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
472
473
474
|
# File 'lib/groonga/expression-builder.rb', line 472
def n_sub_records
self["_nsubrecs"]
end
|
468
469
470
|
# File 'lib/groonga/expression-builder.rb', line 468
def score
self["_score"]
end
|