Class: BuildCloud::S3Bucket
- Inherits:
-
Object
- Object
- BuildCloud::S3Bucket
- Includes:
- Component
- Defined in:
- lib/build-cloud/s3bucket.rb
Constant Summary collapse
- @@objects =
[]
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ S3Bucket
constructor
A new instance of S3Bucket.
- #read ⇒ Object (also: #fog_object)
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ S3Bucket
Returns a new instance of S3Bucket.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/build-cloud/s3bucket.rb', line 7 def initialize ( fog_interfaces, log, = {} ) @s3 = fog_interfaces[:s3] @log = log = @log.debug( .inspect ) (:key, :location) end |
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/build-cloud/s3bucket.rb', line 19 def create return if exists? @log.info( "Creating new S3 bucket #{@options[:key]}" ) bucket = @s3.directories.new( ) bucket.save @log.debug( bucket.inspect ) end |
#delete ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/build-cloud/s3bucket.rb', line 38 def delete return unless exists? @log.info( "Deleting S3 bucket #{@options[:key]}" ) fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
32 33 34 |
# File 'lib/build-cloud/s3bucket.rb', line 32 def read @s3.directories.select { |d| d.key == [:key] }.first end |