Class: RailsRoutesAnalyzer::RouteIssue::Base
- Inherits:
-
Hash
- Object
- Hash
- RailsRoutesAnalyzer::RouteIssue::Base
show all
- Defined in:
- lib/rails_routes_analyzer/route_issue/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
26
27
28
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 26
def initialize(opts = {})
update(opts)
end
|
Class Method Details
.fields(*names) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 7
def self.fields(*names)
names.each do |name|
define_method(name) { self[name] }
define_method("#{name}=") { |val| self[name] = val }
end
end
|
Instance Method Details
#append_verbose_message(message) ⇒ Object
45
46
47
48
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 45
def append_verbose_message(message)
verbose = verbose_message
message << "| #{verbose}" if verbose.present?
end
|
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 54
def format_actions(actions)
case actions.size
when 0
nil
when 1
":#{actions.first}"
else
list = actions.map { |action| ":#{action}" }.sort.join(', ')
"[#{list}]"
end
end
|
#human_readable_error(verbose: false) ⇒ Object
30
31
32
33
34
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 30
def human_readable_error(verbose: false)
human_readable_error_message.tap do |message|
append_verbose_message(message) if verbose
end
end
|
#suggestion(verbose: false, **kwargs) ⇒ Object
39
40
41
42
43
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 39
def suggestion(verbose: false, **kwargs)
error_suggestion(**kwargs).tap do |message|
append_verbose_message(message) if verbose
end
end
|
#try_to_fix_line(_line) ⇒ Object
50
51
52
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 50
def try_to_fix_line(_line)
raise NotImplementedError, 'should be provided by subclasses'
end
|
#verbose_message ⇒ Object
36
37
|
# File 'lib/rails_routes_analyzer/route_issue/base.rb', line 36
def verbose_message
end
|