Class: Google::ObjectStore
- Inherits:
-
Object
- Object
- Google::ObjectStore
- Includes:
- Singleton
- Defined in:
- lib/google/object_store.rb
Overview
A helper class to aggregate all resources when multiple providers produce them at the same time. This singleton is used to collect different “flavors” of resources, managed by different providers, when the client does not care which provider created it.
For example when authenticating requests, as long as the resource honors the “authenticate” API which provider, or which parameters it needed to create itself matters little to the consumer of the authenticator.
Instance Attribute Summary collapse
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #[](type) ⇒ Object
-
#add(type, resource) ⇒ Object
Adds an instance of the resource to the global collection.
-
#initialize ⇒ ObjectStore
constructor
A new instance of ObjectStore.
Constructor Details
#initialize ⇒ ObjectStore
Returns a new instance of ObjectStore.
28 29 30 |
# File 'lib/google/object_store.rb', line 28 def initialize @resources = {} end |
Instance Attribute Details
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
26 27 28 |
# File 'lib/google/object_store.rb', line 26 def resources @resources end |
Instance Method Details
#[](type) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/google/object_store.rb', line 39 def [](type) if @resources[type].nil? [] else @resources[type] end end |
#add(type, resource) ⇒ Object
Adds an instance of the resource to the global collection.
33 34 35 36 37 |
# File 'lib/google/object_store.rb', line 33 def add(type, resource) Puppet.debug "Registering resource #{resource}" @resources[type] = [] if @resources[type].nil? @resources[type] << resource end |