Sha256: 97b68a6ea5c783aa6d9cb0a7a943109f6192745cc30986e1957aeecd60de1812

Contents?: true

Size: 979 Bytes

Versions: 5

Compression:

Stored size: 979 Bytes

Contents

require 'fog'

module Stackster
  class AWS
    class SimpleDB

      def initialize(args)
        c = args[:config]
        @connect = Fog::AWS::SimpleDB.new :aws_access_key_id     => c.access_key,
                                          :aws_secret_access_key => c.secret_key,
                                          :region                => c.region
      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)
        @connect.select(query, 'ConsistentRead' => true).body['Items']
      end

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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stackster-0.4.1 lib/stackster/aws/simpledb.rb
stackster-0.4.0 lib/stackster/aws/simpledb.rb
stackster-0.3.2 lib/stackster/aws/simpledb.rb
stackster-0.3.1 lib/stackster/aws/simpledb.rb
stackster-0.3.0 lib/stackster/aws/simpledb.rb