Class: Racket::Utils::Helpers::HelperCache

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/helpers.rb

Overview

Cache for helpers, ensuring that helpers get loaded exactly once.

Instance Method Summary collapse

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.

Parameters:

  • helpers (Array)

    An array of symbols

Returns:

  • (Hash)


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