class Itamae::Recipe::InstanceEval

Public Class Methods

new(src, path, lineno, context:) click to toggle source
# File lib/itamae/recipe.rb, line 155
      def initialize(src, path, lineno, context:)
        # Using instance_eval + eval to allow top-level class/module definition without `::`.
        # To pass args without introducing any local/instance variables, this code is also eval-ed.
        @code = <<-RUBY
          @context.instance_eval do
            eval(#{src.dump}, nil, #{path.dump}, #{lineno})
          end
        RUBY
        @context = context
      end

Public Instance Methods

call() click to toggle source

This method has no local variables to avoid spilling them to recipes.

# File lib/itamae/recipe.rb, line 167
def call
  eval(@code)
end