PRISM is amazing and opens a new way to access metadata in Ruby. However:
- Loading and reloading the Abstract Syntax Tree (AST) multiple times is inefficient
- Navigating the AST can be difficult
Lowkey provides a central API to make storing and accessing the AST more efficient and easier.
Copy and paste the following and change the defaults to configure Lowkey:
# This configuration should be set before calling "Lowkey.load".
Lowkey.configure do |config|
# A big benefit of Lowkey is its caching of abstract syntax trees, file proxies and class proxies.
# But to save memory you should clear them after the "class load"/setup stage of your application.
# Set to "false" or call "Lowkey.clear" after you no longer need Lowkey, such as in a boot script.
config.cache = true
endAdd gem 'lowkey' to your Gemfile then:
bundle install