Module: Droonga::Searcher::RecordsFormattable
- Included in:
- ComplexRecordsFormatter, SimpleRecordsFormatter
- Defined in:
- lib/droonga/searcher.rb
Instance Method Summary collapse
- #format_records(output_target_attributes, records, output_limit, output_offset) ⇒ Object
- #record_value(record, attribute) ⇒ Object
Instance Method Details
#format_records(output_target_attributes, records, output_limit, output_offset) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/droonga/searcher.rb', line 518 def format_records(output_target_attributes, records, output_limit, output_offset) = { :offset => output_offset, :limit => output_limit } formatted_records = nil records.open_cursor() do |cursor| formatted_records = cursor.collect do |record| format_record(output_target_attributes, record) end end formatted_records end |
#record_value(record, attribute) ⇒ Object
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/droonga/searcher.rb', line 490 def record_value(record, attribute) if attribute[:source] == "_subrecs" if record.table.is_a?(Groonga::Array) target_record = record.value else target_record = record end target_record.sub_records.collect do |sub_record| sub_attributes = attribute[:attributes] format_record(sub_attributes, sub_record) end else expression = attribute[:expression] if expression variable = attribute[:variable] variable.value = record expression.execute else value = record[attribute[:source]] if value.is_a?(Groonga::Record) value.record_id else value end end end end |