Class: S3Repo::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/s3repo/client.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
7
8
9
10
|
# File 'lib/s3repo/client.rb', line 7
def initialize(params = {})
@options = params
@api = Aws::S3::Client.new(region: region)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/s3repo/client.rb', line 35
def method_missing(method, *args, &block)
return super unless @api.respond_to?(method)
define_singleton_method(method) do |*singleton_args|
params = build_params(singleton_args)
@api.send(method, params)
end
send(method, args.first)
end
|
Instance Method Details
#respond_to_missing?(method, include_all = false) ⇒ Boolean
12
13
14
|
# File 'lib/s3repo/client.rb', line 12
def respond_to_missing?(method, include_all = false)
@api.respond_to?(method, include_all) || super
end
|
#upload(key, body) ⇒ Object
16
17
18
19
|
# File 'lib/s3repo/client.rb', line 16
def upload(key, body)
puts "Uploading #{key}"
put_object key: key, body: body
end
|
#upload_file(key, path) ⇒ Object
21
22
23
|
# File 'lib/s3repo/client.rb', line 21
def upload_file(key, path)
upload(key, File.open(path).read)
end
|