activesupport 5.0.5 → 5.0.6.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: b0b05ea535f84f3f2a8e8774774d2d9634fed81e
|
4
|
+
data.tar.gz: ae29afaa002ad64a2288029041d00ce9035b0de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d86323de362506d77eba428ae1e0d7ab2f5d418c4ff40b37ede75f4300618cac2c66327161e71b3b553e9c14d8d3ba0134bf7576840179d5f0cf551ed3ec39
|
7
|
+
data.tar.gz: 34458926f43d31d48a7132af49cafadf3886bf2da816720c4fac1cb2f6a7bc695ee1d3ec72bf9fd90ab55a369bfbd86366619c2036b743e9823e0b7a7e5cd95e
|
data/CHANGELOG.md
CHANGED
@@ -23,33 +23,53 @@ module ActiveSupport
|
|
23
23
|
module LazyLoadHooks
|
24
24
|
def self.extended(base) # :nodoc:
|
25
25
|
base.class_eval do
|
26
|
-
@load_hooks = Hash.new { |h,k| h[k] = [] }
|
27
|
-
@loaded = Hash.new { |h,k| h[k] = [] }
|
26
|
+
@load_hooks = Hash.new { |h, k| h[k] = [] }
|
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
|
|
32
|
+
# Declares a block that will be executed when a Rails component is fully
|
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.
|
31
39
|
def on_load(name, options = {}, &block)
|
32
40
|
@loaded[name].each do |base|
|
33
|
-
execute_hook(base, options, block)
|
41
|
+
execute_hook(name, base, options, block)
|
34
42
|
end
|
35
43
|
|
36
44
|
@load_hooks[name] << [block, options]
|
37
45
|
end
|
38
46
|
|
39
|
-
def execute_hook(base, options, block)
|
40
|
-
if options[:yield]
|
41
|
-
block.call(base)
|
42
|
-
else
|
43
|
-
base.instance_eval(&block)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
47
|
def run_load_hooks(name, base = Object)
|
48
48
|
@loaded[name] << base
|
49
49
|
@load_hooks[name].each do |hook, options|
|
50
|
-
execute_hook(base, options, hook)
|
50
|
+
execute_hook(name, base, options, hook)
|
51
51
|
end
|
52
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
|
53
73
|
end
|
54
74
|
|
55
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.0.
|
4
|
+
version: 5.0.6.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-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -331,9 +331,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
331
331
|
version: 2.2.2
|
332
332
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
333
333
|
requirements:
|
334
|
-
- - "
|
334
|
+
- - ">"
|
335
335
|
- !ruby/object:Gem::Version
|
336
|
-
version:
|
336
|
+
version: 1.3.1
|
337
337
|
requirements: []
|
338
338
|
rubyforge_project:
|
339
339
|
rubygems_version: 2.6.12
|