params-registry 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/params/registry/instance.rb +23 -21
- data/lib/params/registry/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd8659d212d3467f58e09a552bc105d50e35bea4c695c40f9de744a978e4697
|
4
|
+
data.tar.gz: 03522f0aec72a7d4e3d329051ba18c60a6846cf96e1dfadc8efdea86c801f3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e99fd842ae67daa05f39b60832f2ed03c1446b52b856ac6f661f7b3280cb567b0e7597d0d2f45c288542f14c188ab5be331a3989466c72378bbfdb213b2fca7
|
7
|
+
data.tar.gz: f5f0adaa738a61a7556c7e3e7f8eefccb498b0d835b6c774f56702ea938b8b02827f9c5d1f8289668b4d1719422febb8073b140737ce346c197fdeda34132d9c
|
@@ -74,16 +74,16 @@ class Params::Registry::Instance
|
|
74
74
|
@content = {}
|
75
75
|
@extra = {}
|
76
76
|
|
77
|
-
warn "wtf lol #{@registry[@group].inspect}"
|
77
|
+
# warn "wtf lol #{@registry[@group].inspect}"
|
78
78
|
|
79
79
|
# canonicalize the keys of the struct
|
80
80
|
struct = Types::Input[struct].reduce({}) do |hash, pair|
|
81
81
|
key, value = pair
|
82
82
|
if t = @registry[@group][key]
|
83
|
-
warn "yep #{key.inspect}"
|
83
|
+
# warn "yep #{key.inspect}"
|
84
84
|
hash[t.id] = value
|
85
85
|
else
|
86
|
-
warn "nope #{key.inspect}"
|
86
|
+
# warn "nope #{key.inspect}"
|
87
87
|
@extra[key] = value
|
88
88
|
end
|
89
89
|
|
@@ -182,13 +182,15 @@ class Params::Registry::Instance
|
|
182
182
|
# @return [Hash] basically the same thing, minus its metadata.
|
183
183
|
#
|
184
184
|
def to_h slugs: true, extra: false
|
185
|
-
|
186
|
-
out = @content.dup
|
185
|
+
g = registry[@group]
|
187
186
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
187
|
+
out = {}
|
188
|
+
|
189
|
+
g.templates.each do |t|
|
190
|
+
next unless @content.key? t.id
|
191
|
+
key = slugs ? t.slug || t.id.to_s.to_sym : t.id
|
192
|
+
out[key] = @content[t.id]
|
193
|
+
end
|
192
194
|
|
193
195
|
# XXX maybe enforce the ordering better??
|
194
196
|
out.merge! @extra if extra
|
@@ -196,18 +198,18 @@ class Params::Registry::Instance
|
|
196
198
|
out
|
197
199
|
end
|
198
200
|
|
199
|
-
# Retrieve an {Params::Registry::Instance} that isolates the
|
200
|
-
# intersection of one or more groups
|
201
|
-
#
|
202
|
-
# @param group [Object] the group identifier.
|
203
|
-
# @param extra [false, true] whether to include any "extra" unparsed
|
204
|
-
# parameters.
|
205
|
-
#
|
206
|
-
# @return [Params::Registry::Instance] an instance containing just
|
207
|
-
# the group(s) identified.
|
208
|
-
#
|
209
|
-
def group *group, extra: false
|
210
|
-
end
|
201
|
+
# # Retrieve an {Params::Registry::Instance} that isolates the
|
202
|
+
# # intersection of one or more groups
|
203
|
+
# #
|
204
|
+
# # @param group [Object] the group identifier.
|
205
|
+
# # @param extra [false, true] whether to include any "extra" unparsed
|
206
|
+
# # parameters.
|
207
|
+
# #
|
208
|
+
# # @return [Params::Registry::Instance] an instance containing just
|
209
|
+
# # the group(s) identified.
|
210
|
+
# #
|
211
|
+
# def group *group, extra: false
|
212
|
+
# end
|
211
213
|
|
212
214
|
# Serialize the instance back to a {::URI} query string.
|
213
215
|
#
|