Class: Rod::Rest::ProxyFactory
- Inherits:
-
Object
- Object
- Rod::Rest::ProxyFactory
- Defined in:
- lib/rod/rest/proxy_factory.rb
Instance Method Summary collapse
-
#build(object_description) ⇒ Object
Build new object-proxy from the hash-like
object_description
. -
#initialize(metadata, client, options = {}) ⇒ ProxyFactory
constructor
Creates new proxy factory based on the
metadata
and using given webclient
.
Constructor Details
#initialize(metadata, client, options = {}) ⇒ ProxyFactory
Creates new proxy factory based on the metadata
and using given web client
. Options:
-
proxy_class - the class used to create the resource proxy factories.
-
cache - used to cache created proxy instances
11 12 13 14 15 16 17 18 |
# File 'lib/rod/rest/proxy_factory.rb', line 11 def initialize(,client,={}) proxy_class = [:proxy_class] || Proxy @cache = [:cache] @proxies = {} .each do || @proxies[.name] = proxy_class.new(,client) end end |
Instance Method Details
#build(object_description) ⇒ Object
Build new object-proxy from the hash-like object_description
.
21 22 23 24 25 |
# File 'lib/rod/rest/proxy_factory.rb', line 21 def build(object_description) return from_cache(object_description) if in_cache?(object_description) check_type(object_description[:type]) @proxies[object_description[:type]].new(object_description) end |