Module: Shrine::Plugins::Mirroring::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#mirror_delete?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'lib/shrine/plugins/mirroring.rb', line 47

def mirror_delete?
  opts[:mirroring][:delete]
end

#mirror_delete_block(&block) ⇒ Object


35
36
37
38
39
40
41
# File 'lib/shrine/plugins/mirroring.rb', line 35

def mirror_delete_block(&block)
  if block
    opts[:mirroring][:delete_block] = block
  else
    opts[:mirroring][:delete_block]
  end
end

#mirror_upload?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/shrine/plugins/mirroring.rb', line 43

def mirror_upload?
  opts[:mirroring][:upload]
end

#mirror_upload_block(&block) ⇒ Object


27
28
29
30
31
32
33
# File 'lib/shrine/plugins/mirroring.rb', line 27

def mirror_upload_block(&block)
  if block
    opts[:mirroring][:upload_block] = block
  else
    opts[:mirroring][:upload_block]
  end
end

#mirrors(storage_key = nil) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/shrine/plugins/mirroring.rb', line 15

def mirrors(storage_key = nil)
  if storage_key
    mirrors = opts[:mirroring][:mirror][storage_key]

    fail Error, "no mirrors registered for storage #{storage_key.inspect}" unless mirrors

    Array(mirrors)
  else
    opts[:mirroring][:mirror]
  end
end