Class: MiniPaperclip::Storage::Base
- Inherits:
-
Object
- Object
- MiniPaperclip::Storage::Base
- Defined in:
- lib/mini_paperclip/storage/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#interpolator ⇒ Object
readonly
Returns the value of attribute interpolator.
Instance Method Summary collapse
-
#initialize(attachment, config) ⇒ Base
constructor
A new instance of Base.
- #interpolate(template, style) ⇒ Object
- #path_for(style) ⇒ Object
- #url_for_read(style) ⇒ Object
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(, config) @attachment = @config = config @interpolator = Interpolator.new(, config) @deletes = [] end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
6 7 8 |
# File 'lib/mini_paperclip/storage/base.rb', line 6 def @attachment end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/mini_paperclip/storage/base.rb', line 6 def config @config end |
#interpolator ⇒ Object (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 |