Class: Vidar::Interpolation
- Inherits:
-
Object
- Object
- Vidar::Interpolation
- Defined in:
- lib/vidar/interpolation.rb
Constant Summary collapse
- INTERPOLATION_PATTERN =
/\{\{(\w+)\}\}/
Class Method Summary collapse
Class Method Details
.call(string, getter) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/vidar/interpolation.rb', line 6 def call(string, getter) return unless string fail ArgumentError, "getter must respond_to get." unless getter.respond_to?(:get) string.gsub(INTERPOLATION_PATTERN) do |match| getter.get($1) || ENV[$1] || match # rubocop:disable Style/PerlBackrefs end end |