Class: Summon::Service

Inherits:
Object show all
Defined in:
lib/summon/service.rb

Defined Under Namespace

Classes: Pass

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Service

Returns a new instance of Service.



7
8
9
10
11
12
13
14
15
# File 'lib/summon/service.rb', line 7

def initialize(options = {})
  @url        = options[:url] || "http://api.summon.serialssolutions.com/2.0.0"
  @access_id  = options[:access_id]
  @secret_key = options[:secret_key]
  @client_key = options[:client_key]
  @log        = Log.new(options[:log])
  @benchmark  = options[:benchmark] || Pass.new
  @transport  = options[:transport] || Summon::Transport::Http.new(:url => @url, :access_id => @access_id, :secret_key => @secret_key, :client_key => @client_key, :session_id => options[:session_id], :log => @log, :benchmark => @benchmark)
end

Instance Attribute Details

#access_idObject (readonly)

Returns the value of attribute access_id.



5
6
7
# File 'lib/summon/service.rb', line 5

def access_id
  @access_id
end

#client_keyObject (readonly)

Returns the value of attribute client_key.



5
6
7
# File 'lib/summon/service.rb', line 5

def client_key
  @client_key
end

#transportObject (readonly)

Returns the value of attribute transport.



5
6
7
# File 'lib/summon/service.rb', line 5

def transport
  @transport
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/summon/service.rb', line 5

def url
  @url
end

Instance Method Details

#[](options) ⇒ Object

clone a service with overridden options



32
33
34
# File 'lib/summon/service.rb', line 32

def [](options)
  self.class.new({:url => @url, :access_id => @access_id, :secret_key => @secret_key, :client_key => @client_key, :log => @log.impl, :benchmark => @benchmark}.merge(options))
end

#modify_search(original_search, command) ⇒ Object



27
28
29
# File 'lib/summon/service.rb', line 27

def modify_search(original_search, command)
  search original_search.query.to_hash.merge("s.cmd" => command)
end

#search(params = {}) ⇒ Object



21
22
23
24
25
# File 'lib/summon/service.rb', line 21

def search(params = {})
  connect("/search", params) do |result|
    Summon::Search.new(self,result)
  end
end

#versionObject



17
18
19
# File 'lib/summon/service.rb', line 17

def version
  connect("/version") {|result| result["version"] }
end