Sha256: 12add810e5444cb1b9e472cba8a9172736692eb5e1bf3ada0c2129179f72affe

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

require 'fog/softlayer/models/storage/files'

module Fog
  module Storage
    class Softlayer

      class Directory < Fog::Model

        identity  :key, :aliases => 'name'

        attribute :bytes,   :aliases => 'X-Container-Bytes-Used'
        attribute :count,   :aliases => 'X-Container-Object-Count'
        attribute :public,  :aliases => 'X-Container-Read'

        def destroy
          requires :key
          service.delete_container(key)
          true
        rescue Excon::Errors::NotFound
          false
        end

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

        def public=(new_public)
          attributes[:public] = new_public
        end

        def public
          !!attributes[:public]
        end
        alias_method :public?, :public

        def public_url
          requires :key
          cluster = service.cluster.downcase
          key = Fog::Softlayer.escape(self.key)
          "http://17532.http.#{cluster}.cdn.softlayer.net/#{key}"
        end

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

      end

    end
  end
end

Version data entries

8 entries across 6 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/models/storage/directory.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/models/storage/directory.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/models/storage/directory.rb
fog-softlayer-1.1.4 lib/fog/softlayer/models/storage/directory.rb
fog-softlayer-1.1.3 lib/fog/softlayer/models/storage/directory.rb
fog-softlayer-1.1.2 lib/fog/softlayer/models/storage/directory.rb
fog-softlayer-1.1.1 lib/fog/softlayer/models/storage/directory.rb
fog-softlayer-1.1.0 lib/fog/softlayer/models/storage/directory.rb