Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of instance variables for advanced memoization in Rails/HelperInstanceVariable #1002

Open
wscourge opened this issue May 10, 2023 · 0 comments

Comments

@wscourge
Copy link

wscourge commented May 10, 2023

Is your feature request related to a problem? Please describe.

When I use advanced memoization techniques in a helper method, it gets flagged by Rails/HelperInstanceVariable.

Describe the solution you'd like

I'd like Rails/HelperInstanceVariable to accept assignment to instance variables for memoization purposes, i.e., it should allow methods like the following:

def foo
  return @foo if defined?(@foo)

  @foo ||= expensive_calculation_of_foo_that_can_actually_return_nil_value(bar, baz)
end

Describe alternatives you've considered

I considered moving the method elsewhere, but it doesn't make sense for its location to be dependent on using memoization or not.

Additional context

Shamelessly extended the following: #311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant