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
3def1e1e
Commit
3def1e1e
authored
May 30, 2015
by
Dave Gynn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve interpolation speed and memory usage
parent
e7814861
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
lib/paperclip/interpolations.rb
+12
-3
No files found.
lib/paperclip/interpolations.rb
View file @
3def1e1e
...
@@ -10,6 +10,7 @@ module Paperclip
...
@@ -10,6 +10,7 @@ module Paperclip
# and is not intended for normal use.
# and is not intended for normal use.
def
self
.
[]=
name
,
block
def
self
.
[]=
name
,
block
define_method
(
name
,
&
block
)
define_method
(
name
,
&
block
)
@interpolators_cache
=
nil
end
end
# Hash access of interpolations. Included only for compatibility,
# Hash access of interpolations. Included only for compatibility,
...
@@ -29,11 +30,19 @@ module Paperclip
...
@@ -29,11 +30,19 @@ module Paperclip
# an interpolation pattern for Paperclip to use.
# an interpolation pattern for Paperclip to use.
def
self
.
interpolate
pattern
,
*
args
def
self
.
interpolate
pattern
,
*
args
pattern
=
args
.
first
.
instance
.
send
(
pattern
)
if
pattern
.
kind_of?
Symbol
pattern
=
args
.
first
.
instance
.
send
(
pattern
)
if
pattern
.
kind_of?
Symbol
all
.
reverse
.
inject
(
pattern
)
do
|
result
,
tag
|
result
=
pattern
.
dup
result
.
gsub
(
/:
#{
tag
}
/
)
do
|
match
|
interpolators_cache
.
each
do
|
tag
|
send
(
tag
,
*
args
)
result
.
gsub!
(
tag_pattern_cache
[
tag
])
{
send
(
tag
,
*
args
)
}
end
end
result
end
end
def
self
.
tag_pattern_cache
@tag_pattern_cache
||=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
":
#{
key
}
"
}
end
def
self
.
interpolators_cache
@interpolators_cache
||=
all
.
reverse!
end
end
def
self
.
plural_cache
def
self
.
plural_cache
...
...
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