Module: Railbus
- Defined in:
- lib/railbus.rb,
lib/railbus/version.rb,
lib/generators/railbus/install_generator.rb
Defined Under Namespace
Modules: Generators, RouteSetPresenter Classes: RouteSet
Constant Summary collapse
- CLIENTS =
%w[axios fetch]
- VERSION =
'0.2.1'
Class Method Summary collapse
Class Method Details
.generate(app: Rails.application, client: 'axios', include: [], exclude: [], set_options: 'null') ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/railbus.rb', line 14 def generate( app: Rails.application, client: 'axios', include: [], exclude: [], set_options: 'null' ) route_set = RouteSet.new(app, include, exclude) routes_json = Railbus::RouteSetPresenter.to_h(route_set).to_json js_template = File.join(__dir__, 'railbus', 'templates', 'js.erb') erb_engine = Erubi::Engine.new(File.read(js_template)) # Template uses `routes_json`, `client`, 'set_options' client = client.to_s eval(erb_engine.src) end |