Sha256: cf49d096dc84ac3c81b1bcba7a47d8dead9b16c7d80cd29fdb5f666abea8e274

Contents?: true

Size: 1007 Bytes

Versions: 6

Compression:

Stored size: 1007 Bytes

Contents

require 'fog/core/model'
require 'fog/google/models/storage/files'

module Fog
  module Google
    class Storage

      class Directory < Fog::Model
        extend Fog::Deprecation
        deprecate(:name, :key)
        deprecate(:name=, :key=)

        identity  :key,           :aliases => ['Name', 'name']

        attribute :creation_date, :aliases => 'CreationDate'

        def destroy
          requires :key
          connection.delete_bucket(key)
          true
        rescue Excon::Errors::NotFound
          false
        end

        def files
          @files ||= begin
            Fog::Google::Storage::Files.new(
              :directory    => self,
              :connection   => connection
            )
          end
        end

        def save
          requires :key
          options = {}
          if @location
            options['LocationConstraint'] = @location
          end
          connection.put_bucket(key, options)
          true
        end

      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fog-0.3.13 lib/fog/google/models/storage/directory.rb
fog-0.3.12 lib/fog/google/models/storage/directory.rb
fog-0.3.11 lib/fog/google/models/storage/directory.rb
fog-0.3.10 lib/fog/google/models/storage/directory.rb
fog-0.3.9 lib/fog/google/models/storage/directory.rb
fog-0.3.8 lib/fog/google/models/storage/directory.rb