Class: S3FileHandler::Bucket::Create

Inherits:
S3FileHandler::BaseOperation show all
Defined in:
lib/s3_file_handler/bucket/create.rb

Instance Attribute Summary collapse

Attributes inherited from S3FileHandler::BaseOperation

#client, #errors

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, client: S3FileHandler.client) ⇒ Create

Returns a new instance of Create.



8
9
10
11
# File 'lib/s3_file_handler/bucket/create.rb', line 8

def initialize(bucket_name, client: S3FileHandler.client)
  super(client: client)
  @bucket_name = bucket_name
end

Instance Attribute Details

#bucket_nameObject (readonly)

Returns the value of attribute bucket_name.



6
7
8
# File 'lib/s3_file_handler/bucket/create.rb', line 6

def bucket_name
  @bucket_name
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
# File 'lib/s3_file_handler/bucket/create.rb', line 13

def execute
  handle_aws_errors do
    client.create_bucket(bucket: bucket_name)

    result({ bucket: bucket_name, status: 'created' })
  end
end