Class: MiniPaperclip::Storage::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_paperclip/storage/base.rb

Direct Known Subclasses

Filesystem, S3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment, config) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
# File 'lib/mini_paperclip/storage/base.rb', line 8

def initialize(attachment, config)
  @attachment = attachment
  @config = config
  @interpolator = Interpolator.new(attachment, config)
  @deletes = []
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



6
7
8
# File 'lib/mini_paperclip/storage/base.rb', line 6

def attachment
  @attachment
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/mini_paperclip/storage/base.rb', line 6

def config
  @config
end

#interpolatorObject (readonly)

Returns the value of attribute interpolator.



6
7
8
# File 'lib/mini_paperclip/storage/base.rb', line 6

def interpolator
  @interpolator
end

Instance Method Details

#interpolate(template, style) ⇒ Object



28
29
30
# File 'lib/mini_paperclip/storage/base.rb', line 28

def interpolate(template, style)
  @interpolator.interpolate(template, style)
end

#path_for(style) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/mini_paperclip/storage/base.rb', line 19

def path_for(style)
  template = if @attachment.original_filename.nil?
    @config.url_missing_path
  else
    @config.url_path
  end
  interpolate(template, style)
end

#url_for_read(style) ⇒ Object



15
16
17
# File 'lib/mini_paperclip/storage/base.rb', line 15

def url_for_read(style)
  "#{@config.url_scheme}://#{host}/#{path_for(style)}"
end