hyperloop-config 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/hyperloop-config.gemspec +1 -1
- data/lib/hyperloop/context.rb +19 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75342342daae3957c0ad9e88d1bec7dca6adb2bb
|
4
|
+
data.tar.gz: 57c7e5e204cd0b267591c9c7e0e999b456938c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25a85fc640349989a12f861c8dff13e9d4d02f485e6f587b882b72a79d51d781283bc97ace866f2f3eeb1b4634b0ab4586baf20cc86c924d06a7eec02d4296f0
|
7
|
+
data.tar.gz: a3836f359230798716a5840f19c9da877972ab4f26b2e290e1fa21e2e92d0a717dfed51eb39f45c5184bca28597c80931f9e8e0cf2383a7f9eeae5ef1ef5c1e3
|
data/hyperloop-config.gemspec
CHANGED
data/lib/hyperloop/context.rb
CHANGED
@@ -5,26 +5,32 @@ module Hyperloop
|
|
5
5
|
# the provided block will be rerun and the instance variable re-initialized
|
6
6
|
# when the reset! method is called
|
7
7
|
module Context
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
# Replace @foo ||= ... with
|
9
|
+
# Context.set_var(self, :@foo) { ... }
|
10
|
+
# If reset! has been called then the instance variable will be record, and
|
11
|
+
# will be reset on the next call to reset!
|
12
|
+
# If you want to record the current value of the instance variable then set
|
13
|
+
# force to true.
|
14
|
+
def self.set_var(ctx, var, force: nil)
|
15
|
+
puts "calling set_var(#{var})"
|
16
|
+
inst_value_b4 = ctx.instance_variable_get(var)
|
17
|
+
if @context && !@context[ctx].key?(var) && (force || !inst_value_b4)
|
18
|
+
@context[ctx][var] = (inst_value_b4 && inst_value_b4.dup)
|
19
|
+
end
|
20
|
+
inst_value_b4 || ctx.instance_variable_set(var, yield)
|
14
21
|
end
|
15
22
|
|
16
23
|
def self.reset!(reboot = true)
|
17
|
-
# if @
|
24
|
+
# if @context is already initialized then reset all the instance
|
18
25
|
# vars using their corresponding blocks. Otherwise initialize
|
19
|
-
# @
|
20
|
-
if @
|
21
|
-
@
|
22
|
-
var,
|
23
|
-
context.instance_variable_set(var, block.call)
|
26
|
+
# @context.
|
27
|
+
if @context
|
28
|
+
@context.each do |ctx, vars|
|
29
|
+
vars.each { |var, init| ctx.instance_variable_set(var, init) }
|
24
30
|
end
|
25
31
|
Hyperloop::Application::Boot.run if reboot
|
26
32
|
else
|
27
|
-
@
|
33
|
+
@context = Hash.new { |h, k| h[k] = {} }
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperloop-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- catmando
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|