Method: Puppet::Parser::Scope#ephemeral_from

Defined in:
lib/puppet/parser/scope.rb

#ephemeral_from(match, file = nil, line = nil) ⇒ Object



1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
# File 'lib/puppet/parser/scope.rb', line 1014

def ephemeral_from(match, file = nil, line = nil)
  case match
  when Hash
    # Create local scope ephemeral and set all values from hash
    new_ephemeral(true)
    match.each { |k, v| setvar(k, v, :file => file, :line => line, :ephemeral => true) }
    # Must always have an inner match data scope (that starts out as transparent)
    # In 3x slightly wasteful, since a new nested scope is created for a match
    # (TODO: Fix that problem)
    new_ephemeral(false)
  else
    raise(ArgumentError, _("Invalid regex match data. Got a %{klass}") % { klass: match.class }) unless match.is_a?(MatchData)

    # Create a match ephemeral and set values from match data
    new_match_scope(match)
  end
end