lab42_rgxargs 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/lab42/rgxargs.rb +9 -1
- data/lib/lab42/rgxargs/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: 859bcfceec315a00418253c045cb8819276bafd306e52c36a9f3c1f2f0c657aa
|
4
|
+
data.tar.gz: 1cb197a190eada29279019ef914e98af7015589a8aacfd1e16e3a4c728615892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c31ee9df616a66e6a0463a3778b227395cee9acabed1203d4ce46d840208d65829d9c4b48218453cd74d8f770e03538a737d5c6946cdb6486872fd964cd320
|
7
|
+
data.tar.gz: d817a9984f1853028979f179f97fd4b421a58deed2b081fa359f35351e73209b7183aabd1cf5466b86e4e0a20383d7f0b9927d369645ceaf0a47731085e5af7b
|
data/lib/lab42/rgxargs.rb
CHANGED
@@ -20,10 +20,12 @@ module Lab42
|
|
20
20
|
attr_reader :allowed, :args, :conversions, :defaults, :defined_rules, :errors, :options, :required, :syntaxes
|
21
21
|
|
22
22
|
|
23
|
-
def add_conversion(param, conversion, required=nil, &block)
|
23
|
+
def add_conversion(param, conversion=nil, required=nil, &block)
|
24
24
|
case conversion
|
25
25
|
when Symbol
|
26
26
|
_add_symbolic_conversion(param, conversion, required)
|
27
|
+
when NilClass
|
28
|
+
_add_simple_conversion(param, block)
|
27
29
|
else
|
28
30
|
_add_proc_conversion(param, conversion, block, required)
|
29
31
|
end
|
@@ -95,6 +97,12 @@ module Lab42
|
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
100
|
+
def _add_simple_conversion(param, block)
|
101
|
+
Array(param).each do |para|
|
102
|
+
conversions[para] = block
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
98
106
|
def _add_symbolic_conversion(param, conversion, required)
|
99
107
|
Array(param).each do |para|
|
100
108
|
@required.add para if required == :required
|