Class: Racket::Utils::Helpers::HelperCache
- Inherits:
-
Object
- Object
- Racket::Utils::Helpers::HelperCache
- Defined in:
- lib/racket/utils/helpers.rb
Overview
Cache for helpers, ensuring that helpers get loaded exactly once.
Instance Method Summary collapse
-
#initialize(helper_dir) ⇒ HelperCache
constructor
A new instance of HelperCache.
-
#load_helpers(helpers) ⇒ Hash
Loads helper files and return the loadad modules as a hash.
Constructor Details
#initialize(helper_dir) ⇒ HelperCache
Returns a new instance of HelperCache.
25 26 27 28 |
# File 'lib/racket/utils/helpers.rb', line 25 def initialize(helper_dir) @helper_dir = helper_dir @helpers = {} end |
Instance Method Details
#load_helpers(helpers) ⇒ Hash
Loads helper files and return the loadad modules as a hash. Any helper files that cannot be loaded are excluded from the result.
35 36 37 38 39 40 41 42 |
# File 'lib/racket/utils/helpers.rb', line 35 def load_helpers(helpers) helper_modules = {} helpers.each do |helper| helper_module = load_helper(helper) helper_modules[helper] = helper_module if helper_module end helper_modules end |