mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Privatize unneededly protected methods in Active Support
This commit is contained in:
parent
4db99eb87b
commit
a43e7706be
15 changed files with 46 additions and 56 deletions
|
@ -471,12 +471,12 @@ module ActiveSupport
|
|||
raise NotImplementedError.new("#{self.class.name} does not support clear")
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
# Adds the namespace defined in the options to a pattern designed to
|
||||
# match keys. Implementations that support delete_matched should call
|
||||
# this method to translate a pattern that matches names into one that
|
||||
# matches namespaced keys.
|
||||
def key_matcher(pattern, options)
|
||||
def key_matcher(pattern, options) # :doc:
|
||||
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
|
||||
if prefix
|
||||
source = pattern.source
|
||||
|
@ -493,23 +493,22 @@ module ActiveSupport
|
|||
|
||||
# Reads an entry from the cache implementation. Subclasses must implement
|
||||
# this method.
|
||||
def read_entry(key, options) # :nodoc:
|
||||
def read_entry(key, options)
|
||||
raise NotImplementedError.new
|
||||
end
|
||||
|
||||
# Writes an entry to the cache implementation. Subclasses must implement
|
||||
# this method.
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
raise NotImplementedError.new
|
||||
end
|
||||
|
||||
# Deletes an entry from the cache implementation. Subclasses must
|
||||
# implement this method.
|
||||
def delete_entry(key, options) # :nodoc:
|
||||
def delete_entry(key, options)
|
||||
raise NotImplementedError.new
|
||||
end
|
||||
|
||||
private
|
||||
# Merges the default options with ones specific to a method call.
|
||||
def merged_options(call_options)
|
||||
if call_options
|
||||
|
|
|
@ -66,7 +66,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
def read_entry(key, options)
|
||||
if File.exist?(key)
|
||||
|
@ -98,7 +98,6 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Lock a file for a block so only one process can modify it at a time.
|
||||
def lock_file(file_name, &block)
|
||||
if File.exist?(file_name)
|
||||
|
|
|
@ -26,7 +26,7 @@ module ActiveSupport
|
|||
class MemCacheStore < Store
|
||||
# Provide support for raw values in the local cache strategy.
|
||||
module LocalCacheWithRaw # :nodoc:
|
||||
protected
|
||||
private
|
||||
def read_entry(key, options)
|
||||
entry = super
|
||||
if options[:raw] && local_cache && entry
|
||||
|
@ -35,7 +35,7 @@ module ActiveSupport
|
|||
entry
|
||||
end
|
||||
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
if options[:raw] && local_cache
|
||||
raw_entry = Entry.new(entry.value.to_s)
|
||||
raw_entry.expires_at = entry.expires_at
|
||||
|
@ -143,14 +143,14 @@ module ActiveSupport
|
|||
@data.stats
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
# Read an entry from the cache.
|
||||
def read_entry(key, options) # :nodoc:
|
||||
def read_entry(key, options)
|
||||
rescue_error_with(nil) { deserialize_entry(@data.get(key, options)) }
|
||||
end
|
||||
|
||||
# Write an entry to the cache.
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
method = options && options[:unless_exist] ? :add : :set
|
||||
value = options[:raw] ? entry.value.to_s : entry
|
||||
expires_in = options[:expires_in].to_i
|
||||
|
@ -164,12 +164,10 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
# Delete an entry from the cache.
|
||||
def delete_entry(key, options) # :nodoc:
|
||||
def delete_entry(key, options)
|
||||
rescue_error_with(false) { @data.delete(key) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Memcache keys are binaries. So we need to force their encoding to binary
|
||||
# before applying the regular expression to ensure we are escaping all
|
||||
# characters properly.
|
||||
|
|
|
@ -104,15 +104,15 @@ module ActiveSupport
|
|||
@monitor.synchronize(&block)
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
PER_ENTRY_OVERHEAD = 240
|
||||
|
||||
def cached_size(key, entry) # :nodoc:
|
||||
def cached_size(key, entry)
|
||||
key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD
|
||||
end
|
||||
|
||||
def read_entry(key, options) # :nodoc:
|
||||
def read_entry(key, options)
|
||||
entry = @data[key]
|
||||
synchronize do
|
||||
if entry
|
||||
|
@ -124,7 +124,7 @@ module ActiveSupport
|
|||
entry
|
||||
end
|
||||
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
entry.dup_value!
|
||||
synchronize do
|
||||
old_entry = @data[key]
|
||||
|
@ -141,7 +141,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
def delete_entry(key, options) # :nodoc:
|
||||
def delete_entry(key, options)
|
||||
synchronize do
|
||||
@key_access.delete(key)
|
||||
entry = @data.delete(key)
|
||||
|
@ -150,8 +150,6 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def modify_value(name, amount, options)
|
||||
synchronize do
|
||||
options = merged_options(options)
|
||||
|
|
|
@ -25,15 +25,15 @@ module ActiveSupport
|
|||
def delete_matched(matcher, options = nil)
|
||||
end
|
||||
|
||||
protected
|
||||
def read_entry(key, options) # :nodoc:
|
||||
private
|
||||
def read_entry(key, options)
|
||||
end
|
||||
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
true
|
||||
end
|
||||
|
||||
def delete_entry(key, options) # :nodoc:
|
||||
def delete_entry(key, options)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,8 +105,8 @@ module ActiveSupport
|
|||
value
|
||||
end
|
||||
|
||||
protected
|
||||
def read_entry(key, options) # :nodoc:
|
||||
private
|
||||
def read_entry(key, options)
|
||||
if cache = local_cache
|
||||
cache.fetch_entry(key) { super }
|
||||
else
|
||||
|
@ -114,17 +114,17 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
def write_entry(key, entry, options) # :nodoc:
|
||||
def write_entry(key, entry, options)
|
||||
local_cache.write_entry(key, entry, options) if local_cache
|
||||
super
|
||||
end
|
||||
|
||||
def delete_entry(key, options) # :nodoc:
|
||||
def delete_entry(key, options)
|
||||
local_cache.delete_entry(key, options) if local_cache
|
||||
super
|
||||
end
|
||||
|
||||
def write_cache_value(name, value, options) # :nodoc:
|
||||
def write_cache_value(name, value, options)
|
||||
name = normalize_key(name, options)
|
||||
cache = local_cache
|
||||
cache.mute do
|
||||
|
@ -136,8 +136,6 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def local_cache_key
|
||||
@local_cache_key ||= "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, "_").to_sym
|
||||
end
|
||||
|
|
|
@ -159,9 +159,9 @@ module ActiveSupport
|
|||
|
||||
delegate :<=>, to: :value
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
def sum(sign, time = ::Time.current) #:nodoc:
|
||||
def sum(sign, time = ::Time.current)
|
||||
parts.inject(time) do |t, (type, number)|
|
||||
if t.acts_like?(:time) || t.acts_like?(:date)
|
||||
if type == :seconds
|
||||
|
@ -179,8 +179,6 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def method_missing(method, *args, &block)
|
||||
value.send(method, *args, &block)
|
||||
end
|
||||
|
|
|
@ -280,12 +280,12 @@ module ActiveSupport
|
|||
_new_hash
|
||||
end
|
||||
|
||||
protected
|
||||
def convert_key(key)
|
||||
private
|
||||
def convert_key(key) # :doc:
|
||||
key.kind_of?(Symbol) ? key.to_s : key
|
||||
end
|
||||
|
||||
def convert_value(value, options = {})
|
||||
def convert_value(value, options = {}) # :doc:
|
||||
if value.is_a? Hash
|
||||
if options[:for] == :to_hash
|
||||
value.to_hash
|
||||
|
@ -302,7 +302,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
def set_defaults(target)
|
||||
def set_defaults(target) # :doc:
|
||||
if default_proc
|
||||
target.default_proc = default_proc.dup
|
||||
else
|
||||
|
|
|
@ -361,7 +361,7 @@ module ActiveSupport
|
|||
#
|
||||
# const_regexp("Foo::Bar::Baz") # => "Foo(::Bar(::Baz)?)?"
|
||||
# const_regexp("::") # => "::"
|
||||
def const_regexp(camel_cased_word) #:nodoc:
|
||||
def const_regexp(camel_cased_word)
|
||||
parts = camel_cased_word.split("::".freeze)
|
||||
|
||||
return Regexp.escape(camel_cased_word) if parts.blank?
|
||||
|
|
|
@ -85,7 +85,7 @@ module ActiveSupport
|
|||
logger.error "Could not log #{name.inspect} event. #{e.class}: #{e.message} #{e.backtrace}"
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
%w(info debug warn error fatal unknown).each do |level|
|
||||
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
|
@ -99,7 +99,7 @@ module ActiveSupport
|
|||
# option is set to +true+, it also adds bold to the string. This is based
|
||||
# on the Highline implementation and will automatically append CLEAR to the
|
||||
# end of the returned String.
|
||||
def color(text, color, bold = false)
|
||||
def color(text, color, bold = false) # :doc:
|
||||
return text unless colorize_logging
|
||||
color = self.class.const_get(color.upcase) if color.is_a?(Symbol)
|
||||
bold = bold ? BOLD : ""
|
||||
|
|
|
@ -210,9 +210,9 @@ module ActiveSupport #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
def translate_offset(byte_offset) #:nodoc:
|
||||
def translate_offset(byte_offset)
|
||||
return nil if byte_offset.nil?
|
||||
return 0 if @wrapped_string == ""
|
||||
|
||||
|
@ -224,7 +224,7 @@ module ActiveSupport #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
def chars(string) #:nodoc:
|
||||
def chars(string)
|
||||
self.class.new(string)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,8 +45,8 @@ module ActiveSupport
|
|||
Thread.current[@per_thread_registry_key] ||= new
|
||||
end
|
||||
|
||||
protected
|
||||
def method_missing(name, *args, &block) # :nodoc:
|
||||
private
|
||||
def method_missing(name, *args, &block)
|
||||
# Caches the method definition as a singleton method of the receiver.
|
||||
#
|
||||
# By letting #delegate handle it, we avoid an enclosure that'll capture args.
|
||||
|
|
|
@ -36,7 +36,7 @@ module ActiveSupport
|
|||
# render xml: exception, status: 500
|
||||
# end
|
||||
#
|
||||
# protected
|
||||
# private
|
||||
# def deny_access
|
||||
# ...
|
||||
# end
|
||||
|
|
|
@ -58,7 +58,9 @@ module ActiveSupport
|
|||
|
||||
attr_reader :subscriber, :notifier, :namespace
|
||||
|
||||
def add_event_subscriber(event)
|
||||
private
|
||||
|
||||
def add_event_subscriber(event) # :doc:
|
||||
return if %w{ start finish }.include?(event.to_s)
|
||||
|
||||
pattern = "#{event}.#{namespace}"
|
||||
|
|
|
@ -159,7 +159,7 @@ module ActiveSupport
|
|||
key
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
def _dasherize(key)
|
||||
# $2 must be a non-greedy regex for this to work
|
||||
|
@ -168,7 +168,7 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
# TODO: Add support for other encodings
|
||||
def _parse_binary(bin, entity) #:nodoc:
|
||||
def _parse_binary(bin, entity)
|
||||
case entity["encoding"]
|
||||
when "base64"
|
||||
::Base64.decode64(bin)
|
||||
|
@ -185,8 +185,6 @@ module ActiveSupport
|
|||
f
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_thread_backend
|
||||
Thread.current[:xml_mini_backend]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue