activesupport 5.1.3 → 5.1.4.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b960543d225b135e4d04d05db62be2f2b0df1947
|
4
|
+
data.tar.gz: fbd71c160bc96d9cc9c5a6074ed2be362acfecb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d4249cf68d8a0081fb5a05ec758964cd5ada46730341b66fea1d4e05d7948faac1cdda776af272a80be2da029b536b4bcf89c111c74cbeee00ee8472cbde194
|
7
|
+
data.tar.gz: 17a8135d545e232093dadbe336dc57bf02233da057011f6887a6218c9a1a5a1a8a125da1e516acdfa37fb001bb2b103c97482aceeae3422518c59482cfe23c91
|
data/CHANGELOG.md
CHANGED
@@ -25,33 +25,51 @@ module ActiveSupport
|
|
25
25
|
base.class_eval do
|
26
26
|
@load_hooks = Hash.new { |h, k| h[k] = [] }
|
27
27
|
@loaded = Hash.new { |h, k| h[k] = [] }
|
28
|
+
@run_once = Hash.new { |h, k| h[k] = [] }
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
# Declares a block that will be executed when a Rails component is fully
|
32
33
|
# loaded.
|
34
|
+
#
|
35
|
+
# Options:
|
36
|
+
#
|
37
|
+
# * <tt>:yield</tt> - Yields the object that run_load_hooks to +block+.
|
38
|
+
# * <tt>:run_once</tt> - Given +block+ will run only once.
|
33
39
|
def on_load(name, options = {}, &block)
|
34
40
|
@loaded[name].each do |base|
|
35
|
-
execute_hook(base, options, block)
|
41
|
+
execute_hook(name, base, options, block)
|
36
42
|
end
|
37
43
|
|
38
44
|
@load_hooks[name] << [block, options]
|
39
45
|
end
|
40
46
|
|
41
|
-
def execute_hook(base, options, block)
|
42
|
-
if options[:yield]
|
43
|
-
block.call(base)
|
44
|
-
else
|
45
|
-
base.instance_eval(&block)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
47
|
def run_load_hooks(name, base = Object)
|
50
48
|
@loaded[name] << base
|
51
49
|
@load_hooks[name].each do |hook, options|
|
52
|
-
execute_hook(base, options, hook)
|
50
|
+
execute_hook(name, base, options, hook)
|
53
51
|
end
|
54
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def with_execution_control(name, block, once)
|
57
|
+
unless @run_once[name].include?(block)
|
58
|
+
@run_once[name] << block if once
|
59
|
+
|
60
|
+
yield
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def execute_hook(name, base, options, block)
|
65
|
+
with_execution_control(name, block, options[:run_once]) do
|
66
|
+
if options[:yield]
|
67
|
+
block.call(base)
|
68
|
+
else
|
69
|
+
base.instance_eval(&block)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
55
73
|
end
|
56
74
|
|
57
75
|
extend LazyLoadHooks
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.4.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -327,9 +327,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
327
327
|
version: 2.2.2
|
328
328
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
329
329
|
requirements:
|
330
|
-
- - "
|
330
|
+
- - ">"
|
331
331
|
- !ruby/object:Gem::Version
|
332
|
-
version:
|
332
|
+
version: 1.3.1
|
333
333
|
requirements: []
|
334
334
|
rubyforge_project:
|
335
335
|
rubygems_version: 2.6.12
|