trailblazer-context 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 65fadb8598cd610a092a09bc79d5ebc754d8f09372dd2dd7a044e2435aea6759
4
- data.tar.gz: 9b12d7531efdedaf4786cf0af148657f1db85a500db82538e093254c0ab662bc
3
+ metadata.gz: f888d046e1096b02494a7a5fede3827027321d7553d6a01fb5f7ac2dc9fb43cc
4
+ data.tar.gz: 67f3bd4537ea2671a94ac3a74c55ed2f49ed9e9b58169af8eb2e1767fbc0416b
5
5
  SHA512:
6
- metadata.gz: 80552f09f7744038d0d821abea3ed69e085cd5fea0d8416734f3e2fd9b825c8532743049d0a43123023c58cd2162237360542d5256dc382c4fc2d9c434e43f1a
7
- data.tar.gz: e32733db3688e262e11ae3a955ca75ab3a9546ae172b8815c6c9c1a4d1566ac604d8d0b752707c19dd59b7f8534b8579bf8e013fcdfe9a08968cc531fc261e4d
6
+ metadata.gz: 950342604fd800574b188606453e5dbe2b685fe8bb49c8b4c042d27c4beb91be298c2a4a0e07cc509164b6c5ebc0987785e631f487179dbecffacfb180a11ca3
7
+ data.tar.gz: f8fafddb80a3441a623c0db104776919313ff99f4eea0d2c0aa8826c00ba0fb89319294e0c3f892db11061825d41f67e9d2d68637768ce67be984533c1d92230
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.4
2
+
3
+ * Fix the `IndifferentAccess` name lookup. Since we can't convert all keys to symbols internally (not every options structure has `collect`) we need to have a lookup chain.
4
+
1
5
  # 0.1.3
2
6
 
3
7
  * Introduce `Context::IndifferentAccess` which converts all keys to symbol. This, in turn, allows to use both string and symbol keys everywhere. Currently, the implementation is set via the global method `Context.implementation` and defaults to the new `IndifferentAccess`.
data/Rakefile CHANGED
@@ -10,4 +10,4 @@ end
10
10
 
11
11
  RuboCop::RakeTask.new(:rubocop)
12
12
 
13
- task default: %i[test rubocop]
13
+ task default: %i[test]
@@ -2,22 +2,17 @@ module Trailblazer
2
2
  class Context
3
3
  class IndifferentAccess < Context
4
4
  def [](name)
5
- super(name.to_sym)
6
- end
7
-
8
- def []=(name, value)
9
- super(name.to_sym, value)
5
+ # TODO: well...
6
+ @mutable_options.key?(name.to_sym) and return @mutable_options[name.to_sym]
7
+ @mutable_options.key?(name.to_s) and return @mutable_options[name.to_s]
8
+ @wrapped_options.key?(name.to_sym) and return @wrapped_options[name.to_sym]
9
+ @wrapped_options[name.to_s]
10
10
  end
11
11
 
12
12
  def key?(name)
13
- super(name.to_sym)
13
+ super(name.to_sym) || super(name.to_s)
14
14
  end
15
15
 
16
- def merge(hash)
17
- hash = Hash[hash.collect { |k,v| [k.to_sym, v] }]
18
-
19
- super(hash)
20
- end
21
16
  end
22
17
  end
23
18
  end
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  class Context
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -73,18 +73,21 @@ class ContextWithIndifferentAccessTest < Minitest::Spec
73
73
  flow_options = {}
74
74
  circuit_options = {}
75
75
 
76
- immutable = {model: Object}
76
+ immutable = {model: Object, "policy" => Hash}
77
77
 
78
78
  ctx = Trailblazer::Context.for(immutable, [immutable, flow_options], circuit_options)
79
79
 
80
80
  ctx[:model].must_equal Object
81
81
  ctx["model"].must_equal Object
82
+ ctx[:policy].must_equal Hash
83
+ ctx["policy"].must_equal Hash
82
84
 
83
85
  ctx["contract.default"] = Module
84
86
  ctx["contract.default"].must_equal Module
85
87
  ctx[:"contract.default"].must_equal Module
86
88
 
87
89
  # key?
90
+ ctx.key?("____contract.default").must_equal false
88
91
  ctx.key?("contract.default").must_equal true
89
92
  ctx.key?(:"contract.default").must_equal true
90
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer