Class: Prestashop::Client::Implementation
- Inherits:
-
Object
- Object
- Prestashop::Client::Implementation
- Includes:
- Singleton
- Defined in:
- lib/prestashop/client/implementation.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Class Method Summary collapse
-
.create(api_key, api_url) ⇒ Object
Create new user implementation, keep it in current thread to allow multithearding, see
#new
. -
.current ⇒ Object
Get current client or raise exception, when client isn’t initialized.
Instance Method Summary collapse
-
#initialize(api_key, api_url) ⇒ Implementation
constructor
Initialize new client see Api::Connection#new.
Constructor Details
#initialize(api_key, api_url) ⇒ Implementation
Initialize new client see Api::Connection#new
11 12 13 14 |
# File 'lib/prestashop/client/implementation.rb', line 11 def initialize api_key, api_url @connection = Api::Connection.new api_key, api_url @cache = Cache.new end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
7 8 9 |
# File 'lib/prestashop/client/implementation.rb', line 7 def cache @cache end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/prestashop/client/implementation.rb', line 7 def connection @connection end |
Class Method Details
.create(api_key, api_url) ⇒ Object
Create new user implementation, keep it in current thread to allow multithearding, see #new
20 21 22 23 |
# File 'lib/prestashop/client/implementation.rb', line 20 def create api_key, api_url Thread.current[:prestashop_client] = new api_key, api_url current end |
.current ⇒ Object
Get current client or raise exception, when client isn’t initialized
27 28 29 |
# File 'lib/prestashop/client/implementation.rb', line 27 def current Thread.current[:prestashop_client] ? Thread.current[:prestashop_client] : raise(UnitializedClient) end |