Class: Spice::DataBag
- Inherits:
-
Object
- Object
- Spice::DataBag
- Extended by:
- Persistence
- Includes:
- Persistence, Toy::Store
- Defined in:
- lib/spice/data_bag.rb
Instance Attribute Summary (collapse)
-
- (Array) items
The items attribute.
-
- (String) name
The name attribute.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) do_post
-
- (Boolean) new_record?
Check if the data bag exists on the Chef server.
Methods included from Persistence
all, connection, do_delete, do_put, endpoint, get, included
Instance Attribute Details
- (Array) items
The items attribute
15 |
# File 'lib/spice/data_bag.rb', line 15 attribute :items, Array, :default => [] |
- (String) name
The name attribute
14 |
# File 'lib/spice/data_bag.rb', line 14 attribute :name, String |
Class Method Details
+ (Object) all
19 20 21 |
# File 'lib/spice/data_bag.rb', line 19 def self.all connection.data_bags end |
+ (Object) get(name)
23 24 25 |
# File 'lib/spice/data_bag.rb', line 23 def self.get(name) connection.data_bag(name) end |
Instance Method Details
- (Object) do_post
27 28 29 |
# File 'lib/spice/data_bag.rb', line 27 def do_post response = connection.post("/data", attributes) end |
- (Boolean) new_record?
Check if the data bag exists on the Chef server
32 33 34 35 36 37 38 39 |
# File 'lib/spice/data_bag.rb', line 32 def new_record? begin connection.get("/data/#{name}") return false rescue Spice::Error::NotFound return true end end |