Class: Interfacets::Client::Assets::Loader
- Inherits:
-
Object
- Object
- Interfacets::Client::Assets::Loader
- Defined in:
- lib/interfacets/client/assets.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
Instance Method Summary collapse
-
#initialize(assets) ⇒ Loader
constructor
A new instance of Loader.
- #load(klass) ⇒ Object
- #load_path(path) ⇒ Object
- #loaded?(klass) ⇒ Boolean
- #path_loaded?(path) ⇒ Boolean
Constructor Details
#initialize(assets) ⇒ Loader
Returns a new instance of Loader.
72 73 74 75 76 |
# File 'lib/interfacets/client/assets.rb', line 72 def initialize(assets) @assets = assets @loaded_classes = {} @loaded_paths = {} end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
71 72 73 |
# File 'lib/interfacets/client/assets.rb', line 71 def assets @assets end |
Instance Method Details
#load(klass) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/interfacets/client/assets.rb', line 97 def load(klass) return if loaded?(klass) @loaded_classes[klass] = true return if klass.name.nil? return unless const_map.key?(klass.name) const_map .fetch(klass.name) .each { Assets.logger.debug("klass caused load: #{_1}") load_path(_1) } end |
#load_path(path) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/interfacets/client/assets.rb', line 82 def load_path(path) return if @loaded_paths.key?(path) @loaded_paths[path] = true Assets.logger.debug("loading: #{path}") TOP_LEVEL_BINDING.eval(fs_map.fetch(path), path) Assets.logger.debug("done loading: #{path}") end |
#loaded?(klass) ⇒ Boolean
93 94 95 |
# File 'lib/interfacets/client/assets.rb', line 93 def loaded?(klass) @loaded_classes.key?(klass) end |
#path_loaded?(path) ⇒ Boolean
78 79 80 |
# File 'lib/interfacets/client/assets.rb', line 78 def path_loaded?(path) @loaded_paths.key?(path) end |