Sha256: 372f3e2a5a98f0e451a4e046164af2d82a864b0c39cbda150696fb17ad08c303

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

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

module Fog
  module Storage
    class Aliyun
      class Directory < Fog::Model
        identity :key

        def destroy
          requires :key
          prefix = key + '/'
          ret = service.list_objects(prefix: prefix)['Contents']

          if ret.nil?
            puts ' Not found: Direction not exist!'
            false
          elsif ret.size == 1
            service.delete_container(key)
            true
          else
            raise Fog::Storage::Aliyun::Error, ' Forbidden: Direction not empty!'
            false
          end
        end

        def files
          @files ||= begin
            Fog::Storage::Aliyun::Files.new(
              directory: self,
              service: service
            )
          end
        end

        def public_url
          nil
        end

        def save
          requires :key
          service.put_container(key)
          true
        end
      end
    end
  end
end

Version data entries

10 entries across 8 versions & 2 rubygems

Version Path
fog-aliyun-0.3.7 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.5 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.3 lib/fog/aliyun/models/storage/directory.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directory.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directory.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.2 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.3.1 lib/fog/aliyun/models/storage/directory.rb