Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9f9a02af
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,发现更多精彩内容 >>
提交
9f9a02af
编写于
8月 14, 2010
作者:
J
Josep M. Bach
提交者:
Xavier Noria
8月 15, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Whitespace and example identation
上级
e8ef58a6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
13 deletion
+22
-13
activesupport/lib/active_support/lazy_load_hooks.rb
activesupport/lib/active_support/lazy_load_hooks.rb
+7
-7
activesupport/lib/active_support/log_subscriber.rb
activesupport/lib/active_support/log_subscriber.rb
+2
-2
activesupport/lib/active_support/rescuable.rb
activesupport/lib/active_support/rescuable.rb
+1
-0
activesupport/lib/active_support/secure_random.rb
activesupport/lib/active_support/secure_random.rb
+10
-4
activesupport/lib/active_support/time_with_zone.rb
activesupport/lib/active_support/time_with_zone.rb
+2
-0
未找到文件。
activesupport/lib/active_support/lazy_load_hooks.rb
浏览文件 @
9f9a02af
...
...
@@ -5,17 +5,17 @@
#
# Here is an example where +on_load+ method is called to register a hook.
#
# initializer "active_record.initialize_timezone" do
# ActiveSupport.on_load(:active_record) do
# self.time_zone_aware_attributes = true
# self.default_timezone = :utc
# end
# end
#
initializer "active_record.initialize_timezone" do
#
ActiveSupport.on_load(:active_record) do
#
self.time_zone_aware_attributes = true
#
self.default_timezone = :utc
#
end
#
end
#
# When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked.
# The very last line of +activerecord/lib/active_record/base.rb+ is:
#
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
#
ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
#
module
ActiveSupport
@load_hooks
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
...
...
activesupport/lib/active_support/log_subscriber.rb
浏览文件 @
9f9a02af
...
...
@@ -4,7 +4,7 @@
module
ActiveSupport
# ActiveSupport::LogSubscriber is an object set to consume ActiveSupport::Notifications
# with solely purpose of logging. The log subscriber dispatches notifications to a
# regi
rest
ed object based on its given namespace.
# regi
ster
ed object based on its given namespace.
#
# An example would be Active Record log subscriber responsible for logging queries:
#
...
...
@@ -16,7 +16,7 @@ module ActiveSupport
# end
# end
#
# And it's finally registed as:
# And it's finally registe
re
d as:
#
# ActiveRecord::LogSubscriber.attach_to :active_record
#
...
...
activesupport/lib/active_support/rescuable.rb
浏览文件 @
9f9a02af
...
...
@@ -47,6 +47,7 @@ module ClassMethods
# exception.record.new_record? ? ...
# end
# end
#
def
rescue_from
(
*
klasses
,
&
block
)
options
=
klasses
.
extract_options!
...
...
activesupport/lib/active_support/secure_random.rb
浏览文件 @
9f9a02af
...
...
@@ -46,8 +46,10 @@ module ActiveSupport
# p SecureRandom.random_bytes(10) # => "\016\t{\370g\310pbr\301"
# p SecureRandom.random_bytes(10) # => "\323U\030TO\234\357\020\a\337"
# ...
#
module
SecureRandom
# SecureRandom.random_bytes generates a random binary string.
# Generates a random binary string.
#
# The argument n specifies the length of the result string.
#
...
...
@@ -56,6 +58,7 @@ module SecureRandom
#
# If secure random number generator is not available,
# NotImplementedError is raised.
#
def
self
.
random_bytes
(
n
=
nil
)
n
||=
16
...
...
@@ -124,7 +127,7 @@ def self.random_bytes(n=nil)
raise
NotImplementedError
,
"No random device"
end
#
SecureRandom.hex g
enerates a random hex string.
#
G
enerates a random hex string.
#
# The argument n specifies the length of the random length.
# The length of the result string is twice of n.
...
...
@@ -134,11 +137,12 @@ def self.random_bytes(n=nil)
#
# If secure random number generator is not available,
# NotImplementedError is raised.
#
def
self
.
hex
(
n
=
nil
)
random_bytes
(
n
).
unpack
(
"H*"
)[
0
]
end
#
SecureRandom.base64 g
enerates a random base64 string.
#
G
enerates a random base64 string.
#
# The argument n specifies the length of the random length.
# The length of the result string is about 4/3 of n.
...
...
@@ -148,11 +152,12 @@ def self.hex(n=nil)
#
# If secure random number generator is not available,
# NotImplementedError is raised.
#
def
self
.
base64
(
n
=
nil
)
[
random_bytes
(
n
)].
pack
(
"m*"
).
delete
(
"
\n
"
)
end
#
SecureRandom.random_number g
enerates a random number.
#
G
enerates a random number.
#
# If an positive integer is given as n,
# SecureRandom.random_number returns an integer:
...
...
@@ -161,6 +166,7 @@ def self.base64(n=nil)
# If 0 is given or an argument is not given,
# SecureRandom.random_number returns an float:
# 0.0 <= SecureRandom.random_number() < 1.0.
#
def
self
.
random_number
(
n
=
0
)
if
0
<
n
hex
=
n
.
to_s
(
16
)
...
...
activesupport/lib/active_support/time_with_zone.rb
浏览文件 @
9f9a02af
...
...
@@ -32,6 +32,7 @@ module ActiveSupport
# t > Time.utc(1999) # => true
# t.is_a?(Time) # => true
# t.is_a?(ActiveSupport::TimeWithZone) # => true
#
class
TimeWithZone
def
self
.
name
'Time'
# Report class name as 'Time' to thwart type checking
...
...
@@ -127,6 +128,7 @@ def xmlschema(fraction_digits = 0)
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
# # => "2005/02/01 15:15:10 +0000"
#
def
as_json
(
options
=
nil
)
if
ActiveSupport
::
JSON
::
Encoding
.
use_standard_json_time_format
xmlschema
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录