Sha256: b2d9ced681e87615564c76a4aa0b990de9e8907b2a3e9bf79821bee3f30a95bf

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

require 'fog'

module SimpleDeploy
  class AWS
    class SimpleDB

      include Helpers

      def initialize
        @config  = SimpleDeploy.config
        @connect = Fog::AWS::SimpleDB.new connection_args
      end

      def domains
        @connect.list_domains.body['Domains']
      end

      def domain_exists?(domain)
        domains.include? domain
      end

      def create_domain(domain)
        @connect.create_domain(domain) unless domain_exists?(domain)
      end

      def put_attributes(domain, key, attributes, options)
        @connect.put_attributes domain, key, attributes, options
      end

      def select(query)
        options = { 'ConsistentRead' => true }
        data = {}
        next_token = nil

        while true
          options.merge! 'NextToken' => next_token
          chunk = @connect.select(query, options).body
          data.merge! chunk['Items']
          next_token = chunk['NextToken']
          break unless next_token
        end

        data
      end

      def delete(domain, key)
        @connect.delete_attributes domain, key
      end

      def delete_items(domain, key, attributes)
        @connect.delete_attributes domain, key, attributes
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_deploy-0.10.0 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.10.0.beta.3 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.10.0.beta.2 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.10.0.beta.1 lib/simple_deploy/aws/simpledb.rb