params-registry 0.1.3 → 0.1.5

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: 624a80ddabb8e69e586c3350a22bab9717af67818b97618425f0093606b684a6
4
- data.tar.gz: bce074ab33e21da81a969cd0e780c1b296a7ec0e8b4a738cd3e08da098add826
3
+ metadata.gz: a042bd9fe8e18875fbe751867cf08830d8e23e965c0b4c9053e1948a474fe6da
4
+ data.tar.gz: 37c92f7e5de26e422eda6441696c17319009edf0a57eeac813f118b8d7055c7b
5
5
  SHA512:
6
- metadata.gz: d50aa5edb159bc4159b6d93abe11ef251c2a571bc5a2d3935bb17e743e5027aae20caa9ce757be82b70c77cdfbaea6464afd969da77813fbe44efa2b18ce9ea7
7
- data.tar.gz: d893ba746adaa6cdf04f17022f31452ed88a506c70f1060e519603627784ed3e51d0e7cd52a52d14a66d43882c5ab7d6bb9da2c76cd52e8798d0b36f5c9f1157
6
+ metadata.gz: 3e0c5afa52cc9fde678195fdc48e52c470ca7061d70f478216937a8485b38c5f071904992b53370ce8fba63cbbe397041cbf1c852f476b99edd548f756cad25d
7
+ data.tar.gz: 39e52f72ecf4f60f7834d9f406a5cb98f2d9e161ea5bfe01d34fb3ae821dbb454f4813286056e772457b4a9f1caae75d12681d98220db8c945ba858652c5996e
@@ -63,15 +63,21 @@ class Params::Registry::Instance
63
63
  # resembles the output of `URI.decode_www_form`.
64
64
  #
65
65
  def initialize registry, struct, defaults: false, force: false
66
- struct = Types::Input[struct]
67
- @registry = registry
66
+ if registry.is_a? Params::Registry::Group
67
+ @group = registry
68
+ @registry = registry.registry
69
+ else
70
+ @group = nil
71
+ @registry = registry
72
+ end
73
+
68
74
  @content = {}
69
75
  @extra = {}
70
76
 
71
77
  # canonicalize the keys of the struct
72
- struct = struct.reduce({}) do |hash, pair|
78
+ struct = Types::Input[struct].reduce({}) do |hash, pair|
73
79
  key, value = pair
74
- if t = registry.templates[key]
80
+ if t = registry[@group][key]
75
81
  hash[t.id] = value
76
82
  else
77
83
  extra[key] = value
@@ -92,7 +98,7 @@ class Params::Registry::Instance
92
98
  # warn complements.class
93
99
 
94
100
  # now we get the ranked templates and pass them through
95
- registry.templates.ranked.each do |templates|
101
+ registry[@group].ranked.each do |templates|
96
102
  # give me the intersection of templates
97
103
  templates.values.each do |t|
98
104
 
@@ -3,6 +3,6 @@
3
3
  module Params
4
4
  class Registry
5
5
  # The module version
6
- VERSION = "0.1.3"
6
+ VERSION = "0.1.5"
7
7
  end
8
8
  end
@@ -89,7 +89,7 @@ class Params::Registry
89
89
  template = registry.template_class.new registry, id, **spec
90
90
  end
91
91
 
92
- # amke sure we aren't calling ourselves
92
+ # make sure we aren't calling ourselves
93
93
  registry.templates[id] = template unless registry.templates.equal? self
94
94
 
95
95
  # okay now actually assign
@@ -209,6 +209,18 @@ class Params::Registry
209
209
  "#<#{self.class}: #{id} {#{keys.join ', '}}>"
210
210
  end
211
211
 
212
+ # Process the parameters and return a {Params::Registry::Instance}.
213
+ #
214
+ # @param params
215
+ # [String, URI, Hash{#to_sym => Array}, Array<Array<(#to_sym, Object)>>]
216
+ # the parameter set, in a dizzying variety of inputs.
217
+ #
218
+ # @return [Params::Registry::Instance] the instance.
219
+ #
220
+ def process params
221
+ registry.instance_class.new self, Types::Input[params]
222
+ end
223
+
212
224
  end
213
225
 
214
226
  private
@@ -327,7 +339,7 @@ class Params::Registry
327
339
  # the null id is special; you can't assign to it
328
340
  id = Types::NonNil[id]
329
341
 
330
- @groups[id] = Group.new self, id, templates: spec
342
+ @groups[id] = group_class.new self, id, templates: spec
331
343
  end
332
344
 
333
345
  # Retrieve the names of the groups.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: params-registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-03 00:00:00.000000000 Z
11
+ date: 2024-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-types