Sha256: dae85ee163a89cf61de64a6c34a624f7c9a9017ab8ce47fd07f463eff41e4c93

Contents?: true

Size: 514 Bytes

Versions: 4

Compression:

Stored size: 514 Bytes

Contents

require "singleton"

module Paperclip
  module Storage
    module Gcs
      class BucketRepository
        include Singleton

        CACHE_KEY = self.class.name.freeze

        def self.find(client, bucket_name)
          instance.find(client, bucket_name)
        end

        def find(client, bucket_name)
          buckets[[client, bucket_name]] ||= client.bucket(bucket_name)
        end

        private

        def buckets
          Thread.current[CACHE_KEY] ||= {}
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paperclip-gcs-0.3.3 lib/paperclip/storage/gcs/bucket_repository.rb
paperclip-gcs-0.3.2 lib/paperclip/storage/gcs/bucket_repository.rb
paperclip-gcs-0.3.1 lib/paperclip/storage/gcs/bucket_repository.rb
paperclip-gcs-0.3.0 lib/paperclip/storage/gcs/bucket_repository.rb