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
0f47993c
Commit
0f47993c
authored
May 08, 2009
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the business of interpolation into the interpolations module
parent
04140e5a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
lib/paperclip/attachment.rb
+1
-6
lib/paperclip/interpolations.rb
+8
-0
test/interpolations_test.rb
+8
-0
No files found.
lib/paperclip/attachment.rb
View file @
0f47993c
...
...
@@ -388,12 +388,7 @@ module Paperclip
end
def
interpolate
pattern
,
style
=
default_style
#:nodoc:
interpolations
=
Paperclip
::
Interpolations
.
all
interpolations
.
reverse
.
inject
(
pattern
.
dup
)
do
|
result
,
tag
|
result
.
gsub
(
/:
#{
tag
}
/
)
do
|
match
|
Paperclip
::
Interpolations
.
send
(
tag
,
self
,
style
)
end
end
Paperclip
::
Interpolations
.
interpolate
(
pattern
,
self
,
style
)
end
def
queue_existing_for_delete
#:nodoc:
...
...
lib/paperclip/interpolations.rb
View file @
0f47993c
...
...
@@ -14,6 +14,14 @@ module Paperclip
self
.
instance_methods
(
false
).
sort
end
def
self
.
interpolate
pattern
,
*
args
all
.
reverse
.
inject
(
pattern
.
dup
)
do
|
result
,
tag
|
result
.
gsub
(
/:
#{
tag
}
/
)
do
|
match
|
send
(
tag
,
*
args
)
end
end
end
def
rails_root
attachment
,
style
RAILS_ROOT
end
...
...
test/interpolations_test.rb
View file @
0f47993c
...
...
@@ -75,4 +75,12 @@ class InterpolationsTest < Test::Unit::TestCase
attachment
.
expects
(
:default_style
).
returns
(
:default_style
)
assert_equal
:default_style
,
Paperclip
::
Interpolations
.
style
(
attachment
,
nil
)
end
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
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