class Refile::Shopify::Backend

Attributes

directory[R]
max_size[R]

Public Class Methods

new(max_size: nil, hasher: Refile::RandomHasher.new) click to toggle source
# File lib/refile/shopify.rb, line 12
def initialize(max_size: nil, hasher: Refile::RandomHasher.new)
  @hasher = hasher
  @max_size = max_size
  @store = {}
end

Public Instance Methods

clear!(confirm = nil) click to toggle source
# File lib/refile/shopify.rb, line 54
def clear!(confirm = nil)
  raise Refile::Confirm unless confirm == :confirm
  @store = {}
end
delete(id) click to toggle source
# File lib/refile/shopify.rb, line 32
          def delete(id)
  #@store.delete(id)
  ShopifyAPI::Asset.destroy(id)
end
exists?(id) click to toggle source
# File lib/refile/shopify.rb, line 50
          def exists?(id)
  @store.has_key?(id)
end
get(id) click to toggle source
# File lib/refile/shopify.rb, line 27
          def get(id)
  #Refile::File.new(self, id)
  ShopifyAPI::Asset.new(:key => id, :attach => self)
end
open(id) click to toggle source
# File lib/refile/shopify.rb, line 37
          def open(id)
  ShopifyAPI::Asset.find(id)
  #StringIO.new(@store[id])
end
read(id) click to toggle source
# File lib/refile/shopify.rb, line 42
          def read(id)
  @store[id]
end
size(id) click to toggle source
# File lib/refile/shopify.rb, line 46
          def size(id)
  @store[id].bytesize if exists?(id)
end
upload(uploadable) click to toggle source
# File lib/refile/shopify.rb, line 18
                  def upload(uploadable)
  id = @hasher.hash(uploadable)

  @store[id] = uploadable.read

  #Refile::File.new(self, id)
  ShopifyAPI::Asset.new(:key => id, :attach => self)
end