Sha256: 746ee715877e7936e3a2314c6b2b6c40da8c634de8684499c5a7d152e4d87304

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

module Ridley
  class EncryptedDataBagItem
    class << self
      # Finds a data bag item and decrypts it.
      #
      # @param [Ridley::Connection] connection
      # @param [Ridley::DataBag] data_bag
      # @param [String, #chef_id] object
      #
      # @return [nil, Ridley::DataBagItem]
      def find(connection, data_bag, object)
        find!(connection, data_bag, object)
      rescue Errors::HTTPNotFound
        nil
      end

      # Finds a data bag item and decrypts it. Throws an exception if the item doesn't exist.
      #
      # @param [Ridley::Connection] connection
      # @param [Ridley::DataBag] data_bag
      # @param [String, #chef_id] object
      #
      # @raise [Errors::HTTPNotFound]
      #   if a resource with the given chef_id is not found
      #
      # @return [nil, Ridley::DataBagItem]
      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
    end

    attr_reader :data_bag
    attr_reader :attributes

    # @param [Ridley::Connection] connection
    # @param [Ridley::DataBag] data_bag
    # @param [#to_hash] attributes
    def initialize(connection, data_bag, attributes = {})
      @connection = connection
      @data_bag = data_bag
      @attributes = attributes
    end

    def to_s
      self.attributes
    end

    private

      attr_reader :connection
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ridley-0.7.0.beta lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.6.3 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.6.2 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.6.1 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.6.0 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.5.2 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.5.1 lib/ridley/resources/encrypted_data_bag_item.rb
ridley-0.5.0 lib/ridley/resources/encrypted_data_bag_item.rb