Skip to content

Instantly share code, notes, and snippets.

@Marahin
Created February 9, 2017 10:33
Show Gist options
  • Save Marahin/21cce19d98c5209911368c58f0d6974b to your computer and use it in GitHub Desktop.
Save Marahin/21cce19d98c5209911368c58f0d6974b to your computer and use it in GitHub Desktop.
kappa.rb
module KappaOne
## I want the value of 'test' to be memoized & available in class KappaOneOne and KappaOneTwo
def test
@test ||= some_timetaking_method
end
class KappaOneOne
def initialize
@val = test.to_s
end
end
class KappaOneTwo
def initialize
@val = test.to_s.first(5)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment