Skip to content

Commit

Permalink
Extract output_offset and output_limit method
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Jan 15, 2014
1 parent 039d3ae commit 4ed3d76
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/droonga/searcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ def output_elements
@request.output["elements"] || []
end

def output_offset
@request.output["offset"] || 0
end

def output_limit
@request.output["limit"] || 10
end

def format_count
@result.count
end
Expand All @@ -433,12 +441,12 @@ def output_target_attributes
end

def format_records
params = @request.output

offset = params["offset"] || 0
limit = params["limit"] || 10
formatted_records = nil
@result.records.open_cursor(:offset => offset, :limit => limit) do |cursor|
cursor_options = {
:offset => output_offset,
:limit => output_limit
}
@result.records.open_cursor(cursor_options) do |cursor|
if @request.complex_output?
formatted_records = cursor.collect do |record|
complex_record(output_target_attributes, record)
Expand Down

0 comments on commit 4ed3d76

Please sign in to comment.