Class: Prestashop::Client::Implementation

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/prestashop/client/implementation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#cacheObject (readonly)

Returns the value of attribute cache.



7
8
9
# File 'lib/prestashop/client/implementation.rb', line 7

def cache
  @cache
end

#connectionObject (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

.currentObject

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