Class: ChefAPI::Resource::DataBagItemCollectionProxy
Overview
The mutable collection is a special kind of collection proxy that permits Rails-like attribtue creation, like:
DataBag.first.items.create(id: 'me', thing: 'bar', zip: 'zap')
Instance Method Summary
collapse
#all, #count, #each, #exists?, #fetch, #inspect, #reload!, #to_s
Constructor Details
Returns a new instance of DataBagItemCollectionProxy.
88
89
90
91
|
# File 'lib/chef-api/resources/data_bag.rb', line 88
def initialize(bag)
super(bag, Resource::DataBagItem, nil, bag: bag.name)
end
|
Instance Method Details
#build(data = {}) ⇒ Object
113
114
115
|
# File 'lib/chef-api/resources/data_bag.rb', line 113
def build(data = {})
klass.build(data, prefix)
end
|
#create(data = {}) ⇒ Object
118
119
120
121
122
|
# File 'lib/chef-api/resources/data_bag.rb', line 118
def create(data = {})
klass.create(data, prefix)
ensure
reload!
end
|
#create!(data = {}) ⇒ Object
125
126
127
128
129
|
# File 'lib/chef-api/resources/data_bag.rb', line 125
def create!(data = {})
klass.create!(data, prefix)
ensure
reload!
end
|
#destroy(id) ⇒ Object
99
100
101
102
103
|
# File 'lib/chef-api/resources/data_bag.rb', line 99
def destroy(id)
klass.destroy(id, prefix)
ensure
reload!
end
|
#destroy_all ⇒ Object
106
107
108
109
110
|
# File 'lib/chef-api/resources/data_bag.rb', line 106
def destroy_all
klass.destroy_all(prefix)
ensure
reload!
end
|
#new(data = {}) ⇒ Object
94
95
96
|
# File 'lib/chef-api/resources/data_bag.rb', line 94
def new(data = {})
klass.new(data, prefix, parent)
end
|
#update(id, data = {}) ⇒ Object
132
133
134
|
# File 'lib/chef-api/resources/data_bag.rb', line 132
def update(id, data = {})
klass.update(id, data, prefix)
end
|