Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Implemented performance improvement to interpolator"

This reverts commit 68aea16.
  • Loading branch information...
commit 446a4cdbe182aaabdcc61d508d5abfc48a16409d 1 parent a21869e
@jyurek jyurek authored
View
9 lib/paperclip/interpolations.rb
@@ -27,9 +27,12 @@ def self.all
# and the arguments to pass, which are the attachment and style name.
# You can pass a method name on your record as a symbol, which should turn
# an interpolation pattern for Paperclip to use.
- def self.interpolate(pattern, *args)
- pattern.gsub /:([[:word:]]+)/ do
- Paperclip::Interpolations.respond_to?($1) ? Paperclip::Interpolations.send($1, *args) : ":#{$1}"
+ def self.interpolate pattern, *args
+ pattern = args.first.instance.send(pattern) if pattern.kind_of? Symbol
+ all.reverse.inject(pattern) do |result, tag|
+ result.gsub(/:#{tag}/) do |match|
+ send( tag, *args )
+ end
end
end
View
4 test/attachment_test.rb
@@ -282,8 +282,8 @@ class AttachmentTest < Test::Unit::TestCase
teardown { @file.close }
- should "make sure that they are interpolated correctly as long non-word characters separate them" do
- assert_equal "1024.omg/1024-bbq/:idwhat/000/001/024.wtf", @dummy.avatar.path
+ should "make sure that they are interpolated correctly" do
+ assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path
end
end
View
1  test/interpolations_test.rb
@@ -231,6 +231,7 @@ def url(*args)
should "call all expected interpolations with the given arguments" do
Paperclip::Interpolations.expects(:id).with(:attachment, :style).returns(1234)
Paperclip::Interpolations.expects(:attachment).with(:attachment, :style).returns("attachments")
+ Paperclip::Interpolations.expects(:notreal).never
value = Paperclip::Interpolations.interpolate(":notreal/:id/:attachment", :attachment, :style)
assert_equal ":notreal/1234/attachments", value
end
Please sign in to comment.
Something went wrong with that request. Please try again.