Class: Ridley::DataBagResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/ridley/resources/data_bag_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#all, #connection, #create, #delete, #delete_all, #new, representation, represented_by, resource_path, set_resource_path, #update

Constructor Details

#initialize(connection_registry, data_bag_secret) ⇒ DataBagResource

Returns a new instance of DataBagResource.

Parameters:

  • connection_registry (Celluloid::Registry)
  • data_bag_secret (String)


14
15
16
17
# File 'lib/ridley/resources/data_bag_resource.rb', line 14

def initialize(connection_registry, data_bag_secret)
  super(connection_registry)
  @item_resource = DataBagItemResource.new_link(connection_registry, data_bag_secret)
end

Instance Attribute Details

#item_resourceObject (readonly)

Returns the value of attribute item_resource.



8
9
10
# File 'lib/ridley/resources/data_bag_resource.rb', line 8

def item_resource
  @item_resource
end

Instance Method Details

#find(object) ⇒ nil, Ridley::DataBagResource

Parameters:

  • object (String, #chef_id)

Returns:



22
23
24
25
26
27
28
29
# File 'lib/ridley/resources/data_bag_resource.rb', line 22

def find(object)
  chef_id = object.respond_to?(:chef_id) ? object.chef_id : object
  request(:get, "#{self.class.resource_path}/#{chef_id}")
  new(name: chef_id)
rescue AbortError => ex
  return nil if ex.cause.is_a?(Errors::HTTPNotFound)
  abort(ex.cause)
end