16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/i18nliner/extensions/inferpolation.rb', line 16
def inferpolate_value!(value, options)
value.gsub!(/%\{((@)?\w+(.\w+)*)\}/).each do
match = $~
key = $1
ivar = $2
next match if options[key] || options[key.to_sym]
parts = key.split('.')
receiver = ivar ? instance_variable_get(parts.shift) : self
value = parts.inject(receiver) do |obj, message|
obj.respond_to?(message) ? obj.send(message) : nil
end
next match if value.nil?
new_key = key.sub(/\@/, '').gsub('.', '_')
options[new_key.to_sym] = value
"%{#{new_key}}"
end
end
|