class Vidar::Interpolation

Constants

INTERPOLATION_PATTERN

Public Class Methods

call(string, getter) click to toggle source
# 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