public Method

CompiledTemplates.compile_source(identifier, arg_names, source, initial_line_number = 0, file_name = nil)

Compile the provided source code for the given argument names and with the given initial line number. The identifier should be unique to this source.

The file_name, if provided will appear in backtraces. If not provided, the file_name defaults to the identifier.

This method will return the selector for the compiled version of this method.

Source Code

# File action_view/compiled_templates.rb, line 46
def compile_source(identifier, arg_names, source, initial_line_number = 0, file_name = nil)
  file_name ||= identifier
  name = method_names[full_key(identifier, arg_names)]
  arg_desc = arg_names.empty? ? '' : "(#{arg_names * ', '})"
  fake_file_name = "#{file_name}#{arg_desc}" # Include the arguments for this version (for now)

  method_def = wrap_source(name, arg_names, source)

  begin
    module_eval(method_def, fake_file_name, initial_line_number)
    @mtimes[full_key(identifier, arg_names)] = Time.now
  rescue Exception => e  # errors from compiled source
    e.blame_file! identifier
    raise
  end
  name
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.