Created
May 16, 2019 00:48
-
-
Save rwehresmann/066d6f9eee23c30e46c23abd5d279059 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| Knock::Authenticable.module_eval do | |
| def define_current_entity_getter(entity_class, getter_name) | |
| unless self.respond_to?(getter_name) | |
| memoization_var_name = "@_#{getter_name}" | |
| self.class.send(:define_method, getter_name) do | |
| unless instance_variable_defined?(memoization_var_name) | |
| current = Knock::AuthToken.new(token: token).entity_for(entity_class) | |
| instance_variable_set(memoization_var_name, current) | |
| end | |
| instance_variable_get(memoization_var_name) | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment