Class: Summon::Service
Defined Under Namespace
Classes: Pass
Instance Attribute Summary collapse
-
#access_id ⇒ Object
readonly
Returns the value of attribute access_id.
-
#client_key ⇒ Object
readonly
Returns the value of attribute client_key.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#[](options) ⇒ Object
clone a service with overridden options.
-
#initialize(options = {}) ⇒ Service
constructor
A new instance of Service.
- #modify_search(original_search, command) ⇒ Object
- #search(params = {}) ⇒ Object
- #version ⇒ Object
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( = {}) @url = [:url] || "http://api.summon.serialssolutions.com/2.0.0" @access_id = [:access_id] @secret_key = [:secret_key] @client_key = [:client_key] @log = Log.new([:log]) @benchmark = [:benchmark] || Pass.new @transport = [:transport] || Summon::Transport::Http.new(:url => @url, :access_id => @access_id, :secret_key => @secret_key, :client_key => @client_key, :session_id => [:session_id], :log => @log, :benchmark => @benchmark) end |
Instance Attribute Details
#access_id ⇒ Object (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_key ⇒ Object (readonly)
Returns the value of attribute client_key.
5 6 7 |
# File 'lib/summon/service.rb', line 5 def client_key @client_key end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
5 6 7 |
# File 'lib/summon/service.rb', line 5 def transport @transport end |
#url ⇒ Object (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 []() self.class.new({:url => @url, :access_id => @access_id, :secret_key => @secret_key, :client_key => @client_key, :log => @log.impl, :benchmark => @benchmark}.merge()) 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 |
#version ⇒ Object
17 18 19 |
# File 'lib/summon/service.rb', line 17 def version connect("/version") {|result| result["version"] } end |