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
996ca871
Commit
996ca871
authored
Sep 03, 2011
by
Edison
Committed by
Prem Sichanugrist
Sep 23, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable conditional `pattern` assignment to Interpolations
parent
8d43e19e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
lib/paperclip/interpolations.rb
+2
-0
test/attachment_test.rb
+7
-0
No files found.
lib/paperclip/interpolations.rb
View file @
996ca871
...
...
@@ -25,7 +25,9 @@ module Paperclip
# Perform the actual interpolation. Takes the pattern to interpolate
# and the arguments to pass, which are the attachment and style name.
# You can pass a :symbol as pattern assigning some method in your model class.
def
self
.
interpolate
pattern
,
*
args
pattern
=
args
.
first
.
instance
.
send
(
pattern
)
if
pattern
.
kind_of?
Symbol
all
.
reverse
.
inject
(
pattern
.
dup
)
do
|
result
,
tag
|
result
.
gsub
(
/:
#{
tag
}
/
)
do
|
match
|
send
(
tag
,
*
args
)
...
...
test/attachment_test.rb
View file @
996ca871
...
...
@@ -36,6 +36,13 @@ class AttachmentTest < Test::Unit::TestCase
assert_equal
"fake_models/blegga.png"
,
@attachment
.
url
end
should
"return the url by executing and interpolating the default_url when assigned with symbol as method in attachment model"
do
@attachment
=
attachment
:default_url
=>
:some_method_to_determine_default_url
@model
=
@attachment
.
instance
@model
.
stubs
(
:some_method_to_determine_default_url
).
returns
(
":class/female_:style_blegga.png"
)
assert_equal
"fake_models/female_foostyle_blegga.png"
,
@attachment
.
url
(
:foostyle
)
end
context
"Attachment default_options"
do
setup
do
rebuild_model
...
...
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