Class: Ridley::EncryptedDataBagItem

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, data_bag, attributes = {}) ⇒ EncryptedDataBagItem

Returns a new instance of EncryptedDataBagItem.

Parameters:



40
41
42
43
44
# File 'lib/ridley/resources/encrypted_data_bag_item.rb', line 40

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#data_bagObject (readonly)

Returns the value of attribute data_bag.



34
35
36
# File 'lib/ridley/resources/encrypted_data_bag_item.rb', line 34

def data_bag
  @data_bag
end

Class Method Details

.find(connection, data_bag, object) ⇒ nil, Ridley::DataBagItem

Finds a data bag item and decrypts it.

Parameters:

Returns:



11
12
13
14
15
# File 'lib/ridley/resources/encrypted_data_bag_item.rb', line 11

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

.find!(connection, data_bag, object) ⇒ nil, Ridley::DataBagItem

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

Parameters:

Returns:

Raises:



27
28
29
30
31
# File 'lib/ridley/resources/encrypted_data_bag_item.rb', line 27

def find!(connection, data_bag, object)
  data_bag_item = DataBagItem.find!(connection, data_bag, object)
  data_bag_item.decrypt
  new(connection, data_bag, data_bag_item.attributes)
end

Instance Method Details

#to_sObject



46
47
48
# File 'lib/ridley/resources/encrypted_data_bag_item.rb', line 46

def to_s
  self.attributes
end