Skip to content

Unset an instance variable? #28

@CharlieHawker

Description

@CharlieHawker

We are using render_anywhere to render a series of pages, and as such there is a loop.

There are some instances where instance variables are set on iterations of the loop that won't be needed on the next iteration. Leaving them assigned causes rendering issues, but there is no unset_instance_variable method (or similar).

Re-initializing the object which uses the render_anywhere gem on each iteration of the loop would evidently solve this but would be an expensive operation.

Would adding a method like the following be a viable solution?

def unset_instance_variable(var) 
  rendering_controller.class_eval do
    undef :"#{var}"
    undef :"#{var}="
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions