Method: Puppet::Pops::Visitor#visit_this_class
- Defined in:
- lib/puppet/pops/visitor.rb
#visit_this_class(receiver, clazz, args) ⇒ Object
Visit an explicit receiver
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/puppet/pops/visitor.rb', line 55 def visit_this_class(receiver, clazz, args) raise "Visitor Error: Too few arguments passed. min = #{@min_args}" unless args.length >= @min_args if @max_args raise "Visitor Error: Too many arguments passed. max = #{@max_args}" unless args.length <= @max_args end if method_name = @cache[clazz] return receiver.send(method_name, clazz, *args) else clazz.ancestors().each do |ancestor| name = ancestor.name next if name.nil? method_name = :"#{@message}_#{name.split(DOUBLE_COLON).last}" next unless receiver.respond_to?(method_name, true) @cache[clazz] = method_name return receiver.send(method_name, clazz, *args) end end raise "Visitor Error: the configured receiver (#{receiver.class}) can't handle instance of: #{clazz}" end |