1

I am upgrading an app from Rails 3.2.11 to 3.2.17 and I'm getting the following error message:

DEPRECATION WARNING: ActiveSupport::Memoizable is deprecated and will be removed in future releases, simply use Ruby memoization pattern instead.

I know what memoization is, and the offending code appears to be the following:

def api
  @client.vm_by_name(name) if cluster
end
memoize :api

I'm not quite sure how to memoize this using a ruby memoization pattern. The previous techs have memoized the api method. Anyone got any ideas?

0

1 Answer 1

3

Use this:

def api
  @api ||= @client.vm_by_name(name) if cluster
end

Note on thread safety.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.