123456789_123456789_123456789_123456789_123456789_

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

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(route) ⇒ RouteInfo

[ GitHub ]

  
# 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

Instance Method Details

#view_path(root) (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/unused_routes/unused_routes_command.rb', line 25

def view_path(root)
  File.join(root.path, @controller_name, @action_name)
end