Class: Clearance::Generators::RoutesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Clearance::Generators::RoutesGenerator
- Defined in:
- lib/generators/clearance/routes/routes_generator.rb
Instance Method Summary collapse
- #clearance_routes ⇒ Object private
- #disable_clearance_internal_routes ⇒ Object
- #inject_clearance_routes_into_application_routes ⇒ Object
- #route(routing_code) ⇒ Object private
- #routes_file_path ⇒ Object private
Instance Method Details
#clearance_routes ⇒ Object (private)
22 23 24 |
# File 'lib/generators/clearance/routes/routes_generator.rb', line 22 def clearance_routes File.read(routes_file_path) end |
#disable_clearance_internal_routes ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/generators/clearance/routes/routes_generator.rb', line 12 def disable_clearance_internal_routes inject_into_file( "config/initializers/clearance.rb", " config.routes = false\n", after: "Clearance.configure do |config|\n", ) end |
#inject_clearance_routes_into_application_routes ⇒ Object
8 9 10 |
# File 'lib/generators/clearance/routes/routes_generator.rb', line 8 def inject_clearance_routes_into_application_routes route(clearance_routes) end |
#route(routing_code) ⇒ Object (private)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/clearance/routes/routes_generator.rb', line 30 def route(routing_code) log :route, "all clearance routes" sentinel = /\.routes\.draw do\s*\n/m in_root do inject_into_file( "config/routes.rb", routing_code, after: sentinel, verbose: false, force: true, ) end end |
#routes_file_path ⇒ Object (private)
26 27 28 |
# File 'lib/generators/clearance/routes/routes_generator.rb', line 26 def routes_file_path File.(find_in_source_paths('routes.rb')) end |