Class: Global::SprocketsExtension
- Inherits:
-
Object
- Object
- Global::SprocketsExtension
- Defined in:
- lib/global/engine.rb
Constant Summary collapse
- GLOBAL_JS_ASSET =
'global-js'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ SprocketsExtension
constructor
A new instance of SprocketsExtension.
- #render(context, _empty_hash_wtf) ⇒ Object
Constructor Details
#initialize(filename) ⇒ SprocketsExtension
Returns a new instance of SprocketsExtension.
9 10 11 12 |
# File 'lib/global/engine.rb', line 9 def initialize(filename) @filename = filename @source = yield end |
Class Method Details
.call(input) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/global/engine.rb', line 26 def self.call(input) filename = input[:filename] source = input[:data] context = input[:environment].context_class.new(input) result = run(filename, source, context) context..merge(data: result) end |
.run(_filename, source, context) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/global/engine.rb', line 18 def self.run(_filename, source, context) if GLOBAL_JS_ASSET == context.logical_path configs = Dir.glob("#{Global.config_directory}#{File::SEPARATOR}*.yml") configs.map { |config| context.depend_on(config) } end source end |
Instance Method Details
#render(context, _empty_hash_wtf) ⇒ Object
14 15 16 |
# File 'lib/global/engine.rb', line 14 def render(context, _empty_hash_wtf) self.class.run(@filename, @source, context) end |