Module: Shrine::Plugins::DefaultStorage::AttacherMethods

Defined in:
lib/shrine/plugins/default_storage.rb

Instance Method Summary collapse

Instance Method Details

#cache_keyObject


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/shrine/plugins/default_storage.rb', line 33

def cache_key
  if @cache.respond_to?(:call)
    if @cache.arity == 2
      Shrine.deprecation("Passing record & name argument to default storage block is deprecated and will be removed in Shrine 4. Use a block without arguments instead.")
      @cache.call(record, name).to_sym
    else
      instance_exec(&@cache).to_sym
    end
  else
    super
  end
end

#initialize(**options) ⇒ Object


29
30
31
# File 'lib/shrine/plugins/default_storage.rb', line 29

def initialize(**options)
  super(**shrine_class.opts[:default_storage], **options)
end

#store_keyObject


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/shrine/plugins/default_storage.rb', line 46

def store_key
  if @store.respond_to?(:call)
    if @store.arity == 2
      Shrine.deprecation("Passing record & name argument to default storage block is deprecated and will be removed in Shrine 4. Use a block without arguments instead.")
      @store.call(record, name).to_sym
    else
      instance_exec(&@store).to_sym
    end
  else
    super
  end
end