Class: MiniPaperclip::Interpolator
- Inherits:
-
Object
- Object
- MiniPaperclip::Interpolator
- Defined in:
- lib/mini_paperclip/interpolator.rb
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
Returns the value of attribute attachment.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(attachment, config) ⇒ Interpolator
constructor
A new instance of Interpolator.
- #interpolate(template, style) ⇒ Object
Constructor Details
#initialize(attachment, config) ⇒ Interpolator
Returns a new instance of Interpolator.
7 8 9 10 |
# File 'lib/mini_paperclip/interpolator.rb', line 7 def initialize(, config) @attachment = @config = config end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
Returns the value of attribute attachment.
5 6 7 |
# File 'lib/mini_paperclip/interpolator.rb', line 5 def @attachment end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/mini_paperclip/interpolator.rb', line 5 def config @config end |
Instance Method Details
#interpolate(template, style) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/mini_paperclip/interpolator.rb', line 12 def interpolate(template, style) template.dup.tap do |t| @config.interpolates&.each do |matcher, block| t.gsub!(matcher) { instance_exec(style, &block) } end end end |