Class: Chef::Provisioning::ManagedEntryStore
- Inherits:
-
Object
- Object
- Chef::Provisioning::ManagedEntryStore
- Defined in:
- lib/chef/provisioning/managed_entry_store.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#delete(resource_type, name, action_handler) ⇒ Boolean
Delete the given spec.
-
#delete_data(resource_type, name, action_handler) ⇒ Boolean
Delete the given data.
-
#get(resource_type, name) ⇒ ManagedEntry
Get a spec.
-
#get!(resource_type, name) ⇒ ManagedEntry
Get a spec, erroring out if the data does not exist.
-
#get_data(resource_type, name) ⇒ Hash, Array
Get the given data.
-
#get_or_new(resource_type, name) ⇒ ManagedEntry
Get a spec, or create a new one, depending on whether an entry exists.
-
#identifier(resource_type, name) ⇒ String
Get a globally unique identifier for this resource.
-
#initialize(chef_run_data) ⇒ ManagedEntryStore
constructor
A new instance of ManagedEntryStore.
-
#new_entry(resource_type, name, data = nil) ⇒ Object
Create a new managed entry of the given type.
-
#save_data(resource_type, name, data, action_handler) ⇒ Object
Save the given data.
Constructor Details
#initialize(chef_run_data) ⇒ ManagedEntryStore
Returns a new instance of ManagedEntryStore.
9 10 11 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 9 def initialize(chef_run_data) @chef_run_data = chef_run_data end |
Instance Method Details
#delete(resource_type, name, action_handler) ⇒ Boolean
Delete the given spec.
115 116 117 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 115 def delete(resource_type, name, action_handler) delete_data(resource_type, name, action_handler) end |
#delete_data(resource_type, name, action_handler) ⇒ Boolean
Delete the given data
44 45 46 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 44 def delete_data(resource_type, name, action_handler) raise NotImplementedError, :delete_data end |
#get(resource_type, name) ⇒ ManagedEntry
Get a spec.
71 72 73 74 75 76 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 71 def get(resource_type, name) data = get_data(resource_type, name) if data new_entry(resource_type, name, data) end end |
#get!(resource_type, name) ⇒ ManagedEntry
Get a spec, erroring out if the data does not exist.
99 100 101 102 103 104 105 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 99 def get!(resource_type, name) result = get(resource_type, name) if !result raise "#{identifier(resource_type, name)} not found!" end result end |
#get_data(resource_type, name) ⇒ Hash, Array
Get the given data
21 22 23 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 21 def get_data(resource_type, name) raise NotImplementedError, :get_data end |
#get_or_new(resource_type, name) ⇒ ManagedEntry
Get a spec, or create a new one, depending on whether an entry exists.
86 87 88 89 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 86 def get_or_new(resource_type, name) data = get_data(resource_type, name) new_entry(resource_type, name, data) end |
#identifier(resource_type, name) ⇒ String
Get a globally unique identifier for this resource.
59 60 61 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 59 def identifier(resource_type, name) raise NotImplementedError, :identifier end |
#new_entry(resource_type, name, data = nil) ⇒ Object
Create a new managed entry of the given type.
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 122 def new_entry(resource_type, name, data=nil) case resource_type when :machine MachineSpec.new(self, resource_type, name, data) when :machine_image MachineImageSpec.new(self, resource_type, name, data) when :load_balancer LoadBalancerSpec.new(self, resource_type, name, data) else ManagedEntry.new(self, resource_type, name, data) end end |
#save_data(resource_type, name, data, action_handler) ⇒ Object
Save the given data
32 33 34 |
# File 'lib/chef/provisioning/managed_entry_store.rb', line 32 def save_data(resource_type, name, data, action_handler) raise NotImplementedError, :save_data end |