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, &block) ⇒ SprocketsExtension
constructor
A new instance of SprocketsExtension.
- #render(context, empty_hash_wtf) ⇒ Object
Constructor Details
#initialize(filename, &block) ⇒ SprocketsExtension
Returns a new instance of SprocketsExtension.
6 7 8 9 |
# File 'lib/global/engine.rb', line 6 def initialize(filename, &block) @filename = filename @source = block.call end |
Class Method Details
.call(input) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/global/engine.rb', line 23 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
15 16 17 18 19 20 21 |
# File 'lib/global/engine.rb', line 15 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
11 12 13 |
# File 'lib/global/engine.rb', line 11 def render(context, empty_hash_wtf) self.class.run(@filename, @source, context) end |