Class: Papertrail::SearchQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/papertrail/search_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, query = nil, options = {}) ⇒ SearchQuery

Returns a new instance of SearchQuery.



5
6
7
8
9
# File 'lib/papertrail/search_query.rb', line 5

def initialize(connection, query = nil, options = {})
  @connection = connection
  @query      = query
  @options    = options
end

Instance Method Details

#searchObject



11
12
13
14
15
16
17
18
19
# File 'lib/papertrail/search_query.rb', line 11

def search
  params = @options.dup
  params[:q] = @query  if @query
  params[:min_id] = @max_id if @max_id

  response = @connection.get('/api/v1/events/search.json', params)
  @max_id = response.body['max_id']
  Papertrail::SearchResult.new(response.body)
end