lib/puppet/parser/ast/collexpr.rb
# We return an object that does a late-binding evaluation.
We return an object that does a late-binding evaluation.
We return an object that does a late - binding evaluation .
def evaluate(scope)
    [@test1, @test2].each do |t|
      if t.is_a?(self.class)
        t.form ||= self.form
        t.type ||= self.type
      end
    end
    match1, code1 = @test1.safeevaluate scope
    match2, code2 = @test2.safeevaluate scope
    code = proc do |resource|
      case @oper
      when "and"; code1.call(resource) and code2.call(resource)
      when "or"; code1.call(resource) or code2.call(resource)
      when "=="
        if match1 == "tag"
          resource.tagged?(match2)
        else
          if resource[match1].is_a?(Array)
            resource[match1].include?(match2)
          else
            resource[match1] == match2
          end
        end
      when "!="; resource[match1] != match2
      end
    end
    match = [match1, @oper, match2]
    return match, code
  end
def evaluate ( scope ) [ @test1 , @test2 ] . each do | t | if t . is_a? ( self . class ) t . form ||= self . form t . type ||= self . type end end match1 , code1 = @test1 . safeevaluate scope match2 , code2 = @test2 . safeevaluate scope code = proc do | resource | case @oper when "and" ; code1 . call ( resource ) and code2 . call ( resource ) when "or" ; code1 . call ( resource ) or code2 . call ( resource ) when "==" if match1 == "tag" resource . tagged? ( match2 ) else if resource [ match1 ] . is_a? ( Array ) resource [ match1 ] . include? ( match2 ) else resource [ match1 ] == match2 end end when "!=" ; resource [ match1 ] != match2 end end match = [ match1 , @oper , match2 ] return match , code end
We return an object that does a late-binding evaluation.
We return an object that does a late - binding evaluation .
# Make sure our contained expressions have all the info they need. # The code is only used for virtual lookups # First build up the virtual code. # If we're a conjunction operator, then we're calling code.  I did # some speed comparisons, and it's at least twice as fast doing these # case statements as doing an eval here.
scope
<not_specific>