Class: JsRoutesSprocketsExtension
- Inherits:
-
Object
- Object
- JsRoutesSprocketsExtension
- Defined in:
- lib/js_routes/engine.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename, &block) ⇒ JsRoutesSprocketsExtension
constructor
A new instance of JsRoutesSprocketsExtension.
- #render(context, empty_hash_wtf) ⇒ Object
Constructor Details
#initialize(filename, &block) ⇒ JsRoutesSprocketsExtension
Returns a new instance of JsRoutesSprocketsExtension.
2 3 4 5 |
# File 'lib/js_routes/engine.rb', line 2 def initialize(filename, &block) @filename = filename @source = block.call end |
Class Method Details
.call(input) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/js_routes/engine.rb', line 19 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
11 12 13 14 15 16 17 |
# File 'lib/js_routes/engine.rb', line 11 def self.run(filename, source, context) if context.logical_path == 'js-routes' routes = Rails.root.join('config', 'routes.rb').to_s context.depend_on(routes) end source end |
Instance Method Details
#render(context, empty_hash_wtf) ⇒ Object
7 8 9 |
# File 'lib/js_routes/engine.rb', line 7 def render(context, empty_hash_wtf) self.class.run(@filename, @source, context) end |