Skip to content

Commit 7f99854

Browse files
committed
Privatize unneededly protected methods in Action View
1 parent b232c51 commit 7f99854

File tree

7 files changed

+32
-39
lines changed

7 files changed

+32
-39
lines changed

actionview/lib/action_view/log_subscriber.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,35 @@ def logger
5151
ActionView::Base.logger
5252
end
5353

54-
protected
54+
private
5555

5656
EMPTY = ""
57-
def from_rails_root(string)
57+
def from_rails_root(string) # :doc:
5858
string = string.sub(rails_root, EMPTY)
5959
string.sub!(VIEWS_PATTERN, EMPTY)
6060
string
6161
end
6262

63-
def rails_root
63+
def rails_root # :doc:
6464
@root ||= "#{Rails.root}/"
6565
end
6666

67-
def render_count(payload)
67+
def render_count(payload) # :doc:
6868
if payload[:cache_hits]
6969
"[#{payload[:cache_hits]} / #{payload[:count]} cache hits]"
7070
else
7171
"[#{payload[:count]} times]"
7272
end
7373
end
7474

75-
def cache_message(payload)
75+
def cache_message(payload) # :doc:
7676
if payload[:cache_hit]
7777
"[cache hit]"
7878
else
7979
"[cache miss]"
8080
end
8181
end
8282

83-
private
84-
8583
def log_rendering_start(payload)
8684
info do
8785
message = " Rendering #{from_rails_root(payload[:identifier])}"

actionview/lib/action_view/lookup_context.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def disable_cache
9393
@cache = old_value
9494
end
9595

96-
protected
96+
private
9797

98-
def _set_detail(key, value)
98+
def _set_detail(key, value) # :doc:
9999
@details = @details.dup if @details_key
100100
@details_key = nil
101101
@details[key] = value
@@ -149,16 +149,16 @@ def with_fallbacks
149149
added_resolvers.times { view_paths.pop }
150150
end
151151

152-
protected
152+
private
153153

154-
def args_for_lookup(name, prefixes, partial, keys, details_options) #:nodoc:
154+
def args_for_lookup(name, prefixes, partial, keys, details_options)
155155
name, prefixes = normalize_name(name, prefixes)
156156
details, details_key = detail_args_for(details_options)
157157
[name, prefixes, partial || false, details, details_key, keys]
158158
end
159159

160160
# Compute details hash and key according to user options (e.g. passed from #render).
161-
def detail_args_for(options)
161+
def detail_args_for(options) # :doc:
162162
return @details, details_key if options.empty? # most common path.
163163
user_details = @details.merge(options)
164164

@@ -171,13 +171,13 @@ def detail_args_for(options)
171171
[user_details, details_key]
172172
end
173173

174-
def args_for_any(name, prefixes, partial) # :nodoc:
174+
def args_for_any(name, prefixes, partial)
175175
name, prefixes = normalize_name(name, prefixes)
176176
details, details_key = detail_args_for_any
177177
[name, prefixes, partial || false, details, details_key]
178178
end
179179

180-
def detail_args_for_any # :nodoc:
180+
def detail_args_for_any
181181
@detail_args_for_any ||= begin
182182
details = {}
183183

@@ -200,7 +200,7 @@ def detail_args_for_any # :nodoc:
200200
# Support legacy foo.erb names even though we now ignore .erb
201201
# as well as incorrectly putting part of the path in the template
202202
# name instead of the prefix.
203-
def normalize_name(name, prefixes) #:nodoc:
203+
def normalize_name(name, prefixes)
204204
prefixes = prefixes.presence
205205
parts = name.to_s.split("/".freeze)
206206
parts.shift if parts.first.empty?

actionview/lib/action_view/record_identifier.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def dom_id(record, prefix = nil)
9292
end
9393
end
9494

95-
protected
95+
private
9696

9797
# Returns a string representation of the key attribute(s) that is suitable for use in an HTML DOM id.
9898
# This can be overwritten to customize the default generated string representation if desired.
@@ -102,7 +102,7 @@ def dom_id(record, prefix = nil)
102102
# overwritten version of the method. By default, this implementation passes the key string through a
103103
# method that replaces all characters that are invalid inside DOM ids, with valid ones. You need to
104104
# make sure yourself that your dom ids are valid, in case you overwrite this method.
105-
def record_key_for_dom_id(record)
105+
def record_key_for_dom_id(record) # :doc:
106106
key = convert_to_model(record).to_key
107107
key ? key.join(JOIN) : key
108108
end

actionview/lib/action_view/renderer/abstract_renderer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ def render
2525
raise NotImplementedError
2626
end
2727

28-
protected
28+
private
2929

30-
def extract_details(options)
30+
def extract_details(options) # :doc:
3131
@lookup_context.registered_details.each_with_object({}) do |key, details|
3232
value = options[key]
3333

3434
details[key] = Array(value) if value
3535
end
3636
end
3737

38-
def instrument(name, **options)
38+
def instrument(name, **options) # :doc:
3939
options[:identifier] ||= (@template && @template.identifier) || @path
4040

4141
ActiveSupport::Notifications.instrument("render_#{name}.action_view", options) do |payload|
4242
yield payload
4343
end
4444
end
4545

46-
def prepend_formats(formats)
46+
def prepend_formats(formats) # :doc:
4747
formats = Array(formats)
4848
return if formats.empty? || @lookup_context.html_fallback_for_js
4949

actionview/lib/action_view/routing_url_for.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,15 @@ def url_options #:nodoc:
122122
controller.url_options
123123
end
124124

125-
def _routes_context #:nodoc:
125+
private
126+
def _routes_context
126127
controller
127128
end
128-
protected :_routes_context
129129

130-
def optimize_routes_generation? #:nodoc:
130+
def optimize_routes_generation?
131131
controller.respond_to?(:optimize_routes_generation?, true) ?
132132
controller.optimize_routes_generation? : super
133133
end
134-
protected :optimize_routes_generation?
135-
136-
private
137134

138135
def _generate_paths_by_default
139136
true

actionview/lib/action_view/template.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ def encode!
231231
end
232232
end
233233

234-
protected
234+
private
235235

236236
# Compile a template. This method ensures a template is compiled
237237
# just once and removes the source after it is compiled.
238-
def compile!(view) #:nodoc:
238+
def compile!(view)
239239
return if @compiled
240240

241241
# Templates can be used concurrently in threaded environments
@@ -276,7 +276,7 @@ def compile!(view) #:nodoc:
276276
# encode the source into <tt>Encoding.default_internal</tt>.
277277
# In general, this means that templates will be UTF-8 inside of Rails,
278278
# regardless of the original source encoding.
279-
def compile(mod) #:nodoc:
279+
def compile(mod)
280280
encode!
281281
method_name = self.method_name
282282
code = @handler.call(self)
@@ -309,7 +309,7 @@ def #{method_name}(local_assigns, output_buffer)
309309
ObjectSpace.define_finalizer(self, Finalizer[method_name, mod])
310310
end
311311

312-
def handle_render_error(view, e) #:nodoc:
312+
def handle_render_error(view, e)
313313
if e.is_a?(Template::Error)
314314
e.sub_template_of(self)
315315
raise e
@@ -323,7 +323,7 @@ def handle_render_error(view, e) #:nodoc:
323323
end
324324
end
325325

326-
def locals_code #:nodoc:
326+
def locals_code
327327
# Only locals with valid variable names get set directly. Others will
328328
# still be available in local_assigns.
329329
locals = @locals - Module::RUBY_RESERVED_KEYWORDS
@@ -333,24 +333,22 @@ def locals_code #:nodoc:
333333
locals.each_with_object("") { |key, code| code << "#{key} = #{key} = local_assigns[:#{key}];" }
334334
end
335335

336-
def method_name #:nodoc:
336+
protected def method_name #:nodoc:
337337
@method_name ||= begin
338338
m = "_#{identifier_method_name}__#{@identifier.hash}_#{__id__}"
339339
m.tr!("-".freeze, "_".freeze)
340340
m
341341
end
342342
end
343343

344-
def identifier_method_name #:nodoc:
344+
def identifier_method_name
345345
inspect.tr("^a-z_".freeze, "_".freeze)
346346
end
347347

348-
def instrument(action, &block)
348+
def instrument(action, &block) # :doc:
349349
ActiveSupport::Notifications.instrument("#{action}.action_view".freeze, instrument_payload, &block)
350350
end
351351

352-
private
353-
354352
def instrument_render_template(&block)
355353
ActiveSupport::Notifications.instrument("!render_template.action_view".freeze, instrument_payload, &block)
356354
end

actionview/lib/action_view/template/handlers/builder.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def call(template)
1313
";xml.target!;"
1414
end
1515

16-
protected
16+
private
1717

18-
def require_engine
18+
def require_engine # :doc:
1919
@required ||= begin
2020
require "builder"
2121
true

0 commit comments

Comments
 (0)