Sha256: 0580af2f06f91ece12239af59412841ef76b656c728c8edb691a947600a62da1

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

require 'aws-sdk'

module S3Repo
  ##
  # AWS API client
  class Client
    def initialize(params = {})
      @api = Aws::S3::Client.new
      @defaults = params
    end

    def respond_to?(method, include_all = false)
      @api.respond_to?(method, include_all) || super
    end

    private

    def method_missing(method, *args, &block)
      if @api.respond_to?(method) && args.size == 1 && args.first.is_a?(Hash)
        define_singleton_method(method) do |*a|
          @api.send(method, @defaults.dup.merge!(a.first))
        end
        send(method, args.first)
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
s3repo-0.0.1 lib/s3repo/client.rb