Class: Loggly::Search

Inherits:
RemoteModel show all
Defined in:
lib/loggly/models/search.rb

Constant Summary

Constants inherited from RemoteModel

RemoteModel::DEFAULT_RESOURCE_ATTRIBUTES

Constants inherited from Model

Model::METADATA_KEYS

Instance Attribute Summary

Attributes included from RemoteModel::ClassMethods

#resource_attributes

Attributes inherited from Model

#attributes, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RemoteModel::ClassMethods

#all, #collection_name, #create!, #find, #index_method, #path_base, #path_ext, #prepare_params, #set_resource_attributes, #where

Methods inherited from Model

#to_hash, #to_json, #to_log

Methods included from Model::ClassMethods

#from_hash, #from_json

Methods included from Logging

#init_logger, #logger, #logger=

Constructor Details

#initialize(attributes = {}) ⇒ Search

Returns a new instance of Search.



13
14
15
# File 'lib/loggly/models/search.rb', line 13

def initialize(attributes = {})
  super
end

Class Method Details

.create!(conditions = {}, options = {}, &callback) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/loggly/models/search.rb', line 17

def self.create!(conditions = {}, options = {}, &callback)
  options.merge!(:klass => self)
  params = prepare_params(conditions)
  params[:size] = (options[:per_page] ||= @resource_attributes[:per_page])
  params[:page] = (options[:page] ||= 0)

  response = Request.new(@resource_attributes, :get, [path_base, index_method], path_ext, params, options).execute(Loggly.connection)

  model = response.to_model

  callback.call(model) if callback

  model
end