Class: Rails::Command::UnusedRoutesCommand::RouteInfo
Relationships & Source Files | |
Inherits: | Object |
Defined in: | railties/lib/rails/commands/unused_routes/unused_routes_command.rb |
Class Method Summary
- .new(route) ⇒ RouteInfo constructor
Instance Attribute Summary
- #unused? ⇒ Boolean readonly
- #action_missing? ⇒ Boolean readonly private
- #controller_class_missing? ⇒ Boolean readonly private
- #template_missing? ⇒ Boolean readonly private
Instance Method Summary
- #view_path(root) private
Constructor Details
.new(route) ⇒ RouteInfo
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 13
def initialize(route) requirements = route.requirements @controller_name = requirements[:controller] @action_name = requirements[:action] @controller_class = (@controller_name.to_s.camelize + "Controller").safe_constantize end
Instance Attribute Details
#action_missing? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 37
def action_missing? @controller_class && @controller_class.instance_methods.exclude?(@action_name.to_sym) end
#controller_class_missing? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 29
def controller_class_missing? @controller_name && @controller_class.nil? end
#template_missing? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 33
def template_missing? @controller_class && @controller_class.try(:view_paths).to_a.flat_map { |path| Dir["#{view_path(path)}.*"] }.none? end
#unused? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 20
def unused? controller_class_missing? || (action_missing? && template_missing?) end