reverse_parameters 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/reverse_parameters/version.rb +1 -1
- data/lib/reverse_parameters.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: effb6b4959dd2fb08715672c764c4b378589df93
|
4
|
+
data.tar.gz: 6ad27502f30524f5e7d4d607da5a0a52c1c49b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d31b27a32dfb921dc203ff35e7bd17fef1d9aee35890cac9459ae9f885d0ecd8bbe7c1b963e3377e41ccff40bdffa9fa67ceaad8cd726e0764ed4220f6e13e12
|
7
|
+
data.tar.gz: efd233e134289548af65024ceb5c3131197ef99a651d308aa6baa389efc0c7795c11685632723fe4c92ec46e05dc4176c61c42becfe0419bc71c0814c8f953a1
|
data/README.md
CHANGED
@@ -43,11 +43,12 @@ method(:example_method).parameters
|
|
43
43
|
#=> [[:keyreq, :named_param]]
|
44
44
|
```
|
45
45
|
|
46
|
+
To learn more about ruby's parameters method read [Inspecting Method Parameters in Ruby 2.2.3](https://www.rubyplus.com/articles/2721) by RubyPlus.com
|
47
|
+
|
48
|
+
|
46
49
|
## Limitations
|
47
50
|
|
48
|
-
|
49
|
-
There are no consistent of ways of accurately obtaining that what the optional default value is.
|
50
|
-
Since this library's focus is to recreate the public API of a ruby method a default values lies in the private implementation and is out of scope.
|
51
|
+
It is not possible to get the default values using `Proc#parameters` any optional will default to nil.
|
51
52
|
|
52
53
|
## Development
|
53
54
|
|
data/lib/reverse_parameters.rb
CHANGED
@@ -32,7 +32,7 @@ class ReverseParameters
|
|
32
32
|
include Enumerable
|
33
33
|
|
34
34
|
def initialize(collection)
|
35
|
-
@collection = collection.map{|state, name| item_class.new(state: state, name: name)}
|
35
|
+
@collection = collection.map { |state, name| item_class.new(state: state, name: name) }
|
36
36
|
end
|
37
37
|
|
38
38
|
def each(&block)
|
@@ -52,6 +52,7 @@ class ReverseParameters
|
|
52
52
|
@name = name
|
53
53
|
@state = state
|
54
54
|
end
|
55
|
+
|
55
56
|
attr_reader :name, :state
|
56
57
|
end
|
57
58
|
end
|
@@ -62,6 +63,8 @@ class ReverseParameters
|
|
62
63
|
case state
|
63
64
|
when :key, :keyreq
|
64
65
|
"#{name}: #{name}"
|
66
|
+
when :block
|
67
|
+
"&#{name}"
|
65
68
|
else
|
66
69
|
name
|
67
70
|
end.to_s
|
@@ -88,6 +91,8 @@ class ReverseParameters
|
|
88
91
|
"#{name}:"
|
89
92
|
when :key
|
90
93
|
"#{name}: nil"
|
94
|
+
when :block
|
95
|
+
"&#{name}"
|
91
96
|
end.to_s
|
92
97
|
end
|
93
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reverse_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|