hyperloop-config 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95068ff66d67af089b732fc44f910fe3663f19f1
4
- data.tar.gz: aaabff976a2d6a97edda22f99700d38568f49ba1
3
+ metadata.gz: 75342342daae3957c0ad9e88d1bec7dca6adb2bb
4
+ data.tar.gz: 57c7e5e204cd0b267591c9c7e0e999b456938c31
5
5
  SHA512:
6
- metadata.gz: c8dfac20f0ae09fff156473d905e26b15f41c88fae4cde3a304d9f8187e83d866389f73c7484ec58b4f827efea657f104852a21adcd66b695513ec2a17a9ddad
7
- data.tar.gz: 98185f221412cb3ee91b02f0659ae28f68a492596753243df95451a9e641956f989c41bc923d4b0b107e596a13f63cbd3c75051ca8d7f34be409bc241196d943
6
+ metadata.gz: 25a85fc640349989a12f861c8dff13e9d4d02f485e6f587b882b72a79d51d781283bc97ace866f2f3eeb1b4634b0ab4586baf20cc86c924d06a7eec02d4296f0
7
+ data.tar.gz: a3836f359230798716a5840f19c9da877972ab4f26b2e290e1fa21e2e92d0a717dfed51eb39f45c5184bca28597c80931f9e8e0cf2383a7f9eeae5ef1ef5c1e3
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "hyperloop-config"
7
- spec.version = "0.9.5"
7
+ spec.version = "0.9.6"
8
8
  spec.authors = ["catmando"]
9
9
  spec.email = ["mitch@catprint.com"]
10
10
 
@@ -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
- # pass self, an instance var name (symbol) and a block
9
- # if reset! has been called, then record the var and block for future resets
10
- # then if var is currently empty it will be initialized with block
11
- def self.set_var(ctx, var, &block)
12
- @context_hash[ctx] ||= [var, block] if @context_hash
13
- ctx.instance_variable_get(var) || ctx.instance_variable_set(var, yield)
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 @context_hash is already initialized then reset all the instance
24
+ # if @context is already initialized then reset all the instance
18
25
  # vars using their corresponding blocks. Otherwise initialize
19
- # @context_hash.
20
- if @context_hash
21
- @context_hash.each do |context, var_and_block|
22
- var, block = var_and_block
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
- @context_hash = {}
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.5
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-25 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal