Class: Ridley::EncryptedDataBagItemResource

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data_bag, attributes = {}) ⇒ EncryptedDataBagItemResource


41
42
43
44
45
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 41

def initialize(client, data_bag, attributes = {})
  @client     = client
  @data_bag   = data_bag
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes


36
37
38
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 36

def attributes
  @attributes
end

#data_bagObject (readonly)

Returns the value of attribute data_bag


35
36
37
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 35

def data_bag
  @data_bag
end

Class Method Details

.find(client, data_bag, object) ⇒ nil, Ridley::DataBagItemResource

Finds a data bag item and decrypts it.


12
13
14
15
16
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 12

def find(client, data_bag, object)
  find!(client, data_bag, object)
rescue Errors::HTTPNotFound
  nil
end

.find!(client, data_bag, object) ⇒ nil, Ridley::DataBagItemResource

Finds a data bag item and decrypts it. Throws an exception if the item doesn't exist.

Raises:


28
29
30
31
32
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 28

def find!(client, data_bag, object)
  data_bag_item = DataBagItemResource.find!(client, data_bag, object)
  data_bag_item.decrypt
  new(client, data_bag, data_bag_item.attributes)
end

Instance Method Details

#to_sObject


47
48
49
# File 'lib/ridley/resources/encrypted_data_bag_item_resource.rb', line 47

def to_s
  self.attributes
end