Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
446a4cdb
Commit
446a4cdb
authored
Nov 30, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Implemented performance improvement to interpolator"
This reverts commit
68aea16f
.
parent
a21869e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
lib/paperclip/interpolations.rb
+6
-3
test/attachment_test.rb
+2
-2
test/interpolations_test.rb
+1
-0
No files found.
lib/paperclip/interpolations.rb
View file @
446a4cdb
...
...
@@ -27,9 +27,12 @@ module Paperclip
# 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
...
...
test/attachment_test.rb
View file @
446a4cdb
...
...
@@ -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/
:id
what/000/001/024.wtf"
,
@dummy
.
avatar
.
path
should
"make sure that they are interpolated correctly"
do
assert_equal
"1024.omg/1024-bbq/
1024
what/000/001/024.wtf"
,
@dummy
.
avatar
.
path
end
end
...
...
test/interpolations_test.rb
View file @
446a4cdb
...
...
@@ -231,6 +231,7 @@ class InterpolationsTest < Test::Unit::TestCase
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment