Class: WebConsole::Testing::ERBPrecompiler
- Inherits:
-
Object
- Object
- WebConsole::Testing::ERBPrecompiler
- Defined in:
- lib/web_console/testing/erb_precompiler.rb
Overview
This class is to pre-compile ‘templates/*.erb’.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(path) ⇒ ERBPrecompiler
constructor
A new instance of ERBPrecompiler.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(path) ⇒ ERBPrecompiler
Returns a new instance of ERBPrecompiler.
10 11 12 13 14 15 |
# File 'lib/web_console/testing/erb_precompiler.rb', line 10 def initialize(path) @erb = ERB.new(File.read(path)) @view = FakeMiddleware.new( view_path: Helper.gem_root.join("lib/web_console/templates"), ).view end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
21 22 23 24 |
# File 'lib/web_console/testing/erb_precompiler.rb', line 21 def method_missing(name, *args, &block) return super unless @view.respond_to?(name) @view.send(name, *args, &block) end |
Instance Method Details
#build ⇒ Object
17 18 19 |
# File 'lib/web_console/testing/erb_precompiler.rb', line 17 def build @erb.result(binding) end |