class LieutenantGovernor::Generators::JsRouteHelpers
Public Class Methods
generate_paths_file(path)
click to toggle source
Use the extractor to get the hash assume function exists to translate hash to javascript text using Thor, open up a file, and then write the javascript text to the file
# File lib/lieutenant_governor/generators/js_route_helpers.rb, line 17 def self.generate_paths_file(path) raise TypeError.new('Path must be String.') unless path.class == String routes = Rails.application.routes.routes route_table = LieutenantGovernor::Routing::Extractor.extract(routes) template = LieutenantGovernor::Templates::JsPaths.new(route_table) # create_file '/client/paths.js', template.render File.open(path, 'w') do |f| f.puts template.render end end