This repository was archived by the owner on Jul 10, 2018. It is now read-only.
Commit 993a47b 1 parent 3def1e1 commit 993a47b Copy full SHA for 993a47b
File tree 1 file changed +4
-8
lines changed
1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def self.[] name
21
21
22
22
# Returns a sorted list of all interpolations.
23
23
def self . all
24
- self . instance_methods ( false ) . sort
24
+ self . instance_methods ( false ) . sort!
25
25
end
26
26
27
27
# Perform the actual interpolation. Takes the pattern to interpolate
@@ -31,18 +31,14 @@ def self.all
31
31
def self . interpolate pattern , *args
32
32
pattern = args . first . instance . send ( pattern ) if pattern . kind_of? Symbol
33
33
result = pattern . dup
34
- interpolators_cache . each do |tag |
35
- result . gsub! ( tag_pattern_cache [ tag ] ) { send ( tag , *args ) }
34
+ interpolators_cache . each do |method , token |
35
+ result . gsub! ( token ) { send ( method , *args ) } if result . include? ( token )
36
36
end
37
37
result
38
38
end
39
39
40
- def self . tag_pattern_cache
41
- @tag_pattern_cache ||= Hash . new { |hash , key | hash [ key ] = ":#{ key } " }
42
- end
43
-
44
40
def self . interpolators_cache
45
- @interpolators_cache ||= all . reverse!
41
+ @interpolators_cache ||= all . reverse! . map! { | method | [ method , ": #{ method } " ] }
46
42
end
47
43
48
44
def self . plural_cache
You can’t perform that action at this time.
0 commit comments