Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a43e7706
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a43e7706
编写于
12月 17, 2016
作者:
A
Akira Matsuda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Privatize unneededly protected methods in Active Support
上级
4db99eb8
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
46 addition
and
56 deletion
+46
-56
activesupport/lib/active_support/cache.rb
activesupport/lib/active_support/cache.rb
+5
-6
activesupport/lib/active_support/cache/file_store.rb
activesupport/lib/active_support/cache/file_store.rb
+1
-2
activesupport/lib/active_support/cache/mem_cache_store.rb
activesupport/lib/active_support/cache/mem_cache_store.rb
+6
-8
activesupport/lib/active_support/cache/memory_store.rb
activesupport/lib/active_support/cache/memory_store.rb
+5
-7
activesupport/lib/active_support/cache/null_store.rb
activesupport/lib/active_support/cache/null_store.rb
+4
-4
activesupport/lib/active_support/cache/strategy/local_cache.rb
...esupport/lib/active_support/cache/strategy/local_cache.rb
+5
-7
activesupport/lib/active_support/duration.rb
activesupport/lib/active_support/duration.rb
+2
-4
activesupport/lib/active_support/hash_with_indifferent_access.rb
...upport/lib/active_support/hash_with_indifferent_access.rb
+4
-4
activesupport/lib/active_support/inflector/methods.rb
activesupport/lib/active_support/inflector/methods.rb
+1
-1
activesupport/lib/active_support/log_subscriber.rb
activesupport/lib/active_support/log_subscriber.rb
+2
-2
activesupport/lib/active_support/multibyte/chars.rb
activesupport/lib/active_support/multibyte/chars.rb
+3
-3
activesupport/lib/active_support/per_thread_registry.rb
activesupport/lib/active_support/per_thread_registry.rb
+2
-2
activesupport/lib/active_support/rescuable.rb
activesupport/lib/active_support/rescuable.rb
+1
-1
activesupport/lib/active_support/subscriber.rb
activesupport/lib/active_support/subscriber.rb
+3
-1
activesupport/lib/active_support/xml_mini.rb
activesupport/lib/active_support/xml_mini.rb
+2
-4
未找到文件。
activesupport/lib/active_support/cache.rb
浏览文件 @
a43e7706
...
...
@@ -471,12 +471,12 @@ def clear
raise
NotImplementedError
.
new
(
"
#{
self
.
class
.
name
}
does not support clear"
)
end
pr
otected
pr
ivate
# 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 @@ def key_matcher(pattern, options)
# 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
...
...
activesupport/lib/active_support/cache/file_store.rb
浏览文件 @
a43e7706
...
...
@@ -66,7 +66,7 @@ def delete_matched(matcher, options = nil)
end
end
pr
otected
pr
ivate
def
read_entry
(
key
,
options
)
if
File
.
exist?
(
key
)
...
...
@@ -98,7 +98,6 @@ def delete_entry(key, options)
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
)
...
...
activesupport/lib/active_support/cache/mem_cache_store.rb
浏览文件 @
a43e7706
...
...
@@ -26,7 +26,7 @@ module Cache
class
MemCacheStore
<
Store
# Provide support for raw values in the local cache strategy.
module
LocalCacheWithRaw
# :nodoc:
pr
otected
pr
ivate
def
read_entry
(
key
,
options
)
entry
=
super
if
options
[
:raw
]
&&
local_cache
&&
entry
...
...
@@ -35,7 +35,7 @@ def read_entry(key, options)
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 @@ def stats
@data
.
stats
end
pr
otected
pr
ivate
# 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 @@ def write_entry(key, entry, options) # :nodoc:
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.
...
...
activesupport/lib/active_support/cache/memory_store.rb
浏览文件 @
a43e7706
...
...
@@ -104,15 +104,15 @@ def synchronize(&block) # :nodoc:
@monitor
.
synchronize
(
&
block
)
end
pr
otected
pr
ivate
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 @@ def read_entry(key, options) # :nodoc:
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 @@ def write_entry(key, entry, options) # :nodoc:
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 @@ def delete_entry(key, options) # :nodoc:
end
end
private
def
modify_value
(
name
,
amount
,
options
)
synchronize
do
options
=
merged_options
(
options
)
...
...
activesupport/lib/active_support/cache/null_store.rb
浏览文件 @
a43e7706
...
...
@@ -25,15 +25,15 @@ def decrement(name, amount = 1, options = nil)
def
delete_matched
(
matcher
,
options
=
nil
)
end
pr
otected
def
read_entry
(
key
,
options
)
# :nodoc:
pr
ivate
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
...
...
activesupport/lib/active_support/cache/strategy/local_cache.rb
浏览文件 @
a43e7706
...
...
@@ -105,8 +105,8 @@ def decrement(name, amount = 1, options = nil) # :nodoc:
value
end
pr
otected
def
read_entry
(
key
,
options
)
# :nodoc:
pr
ivate
def
read_entry
(
key
,
options
)
if
cache
=
local_cache
cache
.
fetch_entry
(
key
)
{
super
}
else
...
...
@@ -114,17 +114,17 @@ def read_entry(key, options) # :nodoc:
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 @@ def write_cache_value(name, value, options) # :nodoc:
end
end
private
def
local_cache_key
@local_cache_key
||=
"
#{
self
.
class
.
name
.
underscore
}
_local_cache_
#{
object_id
}
"
.
gsub
(
/[\/-]/
,
"_"
).
to_sym
end
...
...
activesupport/lib/active_support/duration.rb
浏览文件 @
a43e7706
...
...
@@ -159,9 +159,9 @@ def iso8601(precision: nil)
delegate
:<=>
,
to: :value
pr
otected
pr
ivate
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 @@ def sum(sign, time = ::Time.current) #:nodoc:
end
end
private
def
method_missing
(
method
,
*
args
,
&
block
)
value
.
send
(
method
,
*
args
,
&
block
)
end
...
...
activesupport/lib/active_support/hash_with_indifferent_access.rb
浏览文件 @
a43e7706
...
...
@@ -280,12 +280,12 @@ def to_hash
_new_hash
end
pr
otected
def
convert_key
(
key
)
pr
ivate
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 @@ def convert_value(value, options = {})
end
end
def
set_defaults
(
target
)
def
set_defaults
(
target
)
# :doc:
if
default_proc
target
.
default_proc
=
default_proc
.
dup
else
...
...
activesupport/lib/active_support/inflector/methods.rb
浏览文件 @
a43e7706
...
...
@@ -361,7 +361,7 @@ def ordinalize(number)
#
# 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?
...
...
activesupport/lib/active_support/log_subscriber.rb
浏览文件 @
a43e7706
...
...
@@ -85,7 +85,7 @@ def finish(name, id, payload)
logger
.
error
"Could not log
#{
name
.
inspect
}
event.
#{
e
.
class
}
:
#{
e
.
message
}
#{
e
.
backtrace
}
"
end
pr
otected
pr
ivate
%w(info debug warn error fatal unknown)
.
each
do
|
level
|
class_eval
<<-
METHOD
,
__FILE__
,
__LINE__
+
1
...
...
@@ -99,7 +99,7 @@ def #{level}(progname = nil, &block)
# 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
:
""
...
...
activesupport/lib/active_support/multibyte/chars.rb
浏览文件 @
a43e7706
...
...
@@ -210,9 +210,9 @@ def as_json(options = nil) #:nodoc:
end
end
pr
otected
pr
ivate
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 @@ def translate_offset(byte_offset) #:nodoc:
end
end
def
chars
(
string
)
#:nodoc:
def
chars
(
string
)
self
.
class
.
new
(
string
)
end
end
...
...
activesupport/lib/active_support/per_thread_registry.rb
浏览文件 @
a43e7706
...
...
@@ -45,8 +45,8 @@ def instance
Thread
.
current
[
@per_thread_registry_key
]
||=
new
end
pr
otected
def
method_missing
(
name
,
*
args
,
&
block
)
# :nodoc:
pr
ivate
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.
...
...
activesupport/lib/active_support/rescuable.rb
浏览文件 @
a43e7706
...
...
@@ -36,7 +36,7 @@ module ClassMethods
# render xml: exception, status: 500
# end
#
# pr
otected
# pr
ivate
# def deny_access
# ...
# end
...
...
activesupport/lib/active_support/subscriber.rb
浏览文件 @
a43e7706
...
...
@@ -58,7 +58,9 @@ def subscribers
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
}
"
...
...
activesupport/lib/active_support/xml_mini.rb
浏览文件 @
a43e7706
...
...
@@ -159,7 +159,7 @@ def rename_key(key, options = {})
key
end
pr
otected
pr
ivate
def
_dasherize
(
key
)
# $2 must be a non-greedy regex for this to work
...
...
@@ -168,7 +168,7 @@ def _dasherize(key)
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 @@ def _parse_file(file, entity)
f
end
private
def
current_thread_backend
Thread
.
current
[
:xml_mini_backend
]
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录