class RailsRoutesAnalyzer::ActionMethod

Public Class Methods

new(opts = {}) click to toggle source
# File lib/rails_routes_analyzer/action_analysis.rb, line 27
def initialize(opts = {})
  update(opts)
end

Public Instance Methods

controller_class() click to toggle source
# File lib/rails_routes_analyzer/action_analysis.rb, line 31
def controller_class
  @controller_class ||= controller_name.constantize
end
needs_reporting?(report_duplicates:, report_gems:, report_modules:, report_routed:, **) click to toggle source
# File lib/rails_routes_analyzer/action_analysis.rb, line 35
def needs_reporting?(report_duplicates:, report_gems:, report_modules:, report_routed:, **)
  (route_missing?     || report_routed)     \
    && (!inherited?   || report_duplicates) \
    && (!from_gem?    || report_gems)       \
    && (!from_module? || report_modules)
end
pretty(max_action_length: MAX_ACTION_LENGTH, metadata: false, **) click to toggle source
# File lib/rails_routes_analyzer/action_analysis.rb, line 42
def pretty(max_action_length: MAX_ACTION_LENGTH, metadata: false, **)
  format("%-#{max_action_length}s @ %s", action_name, source_location).tap do |result|
    if metadata
      result << " "
      result << pretty_metadata
    end
  end
end
pretty_metadata() click to toggle source
# File lib/rails_routes_analyzer/action_analysis.rb, line 51
def pretty_metadata
  [
    route_missing? ? "no-route"                : nil,
    inherited?     ? "inherited:#{owner.name}" : nil,
    from_gem?      ? "gem:#{from_gem}"         : nil,
    from_module?   ? "module:#{owner.name}"    : nil,
  ].compact.join(' ')
end