functo 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/functo/version.rb +1 -1
- data/lib/functo.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edec39c1333fdfbe36d34afdb69a8f58bb5dfb9c
|
4
|
+
data.tar.gz: 14f56acf9d721fdd4b16f169466fe022fa98df20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dadfd017d4a1ed59bf7bb9641ab8674a8c8925d7425eb74a1f2be74f85a85ec131c5c5998d8c72d092a4af249fb0128b36f833a225b721db5881b12cc9fc335
|
7
|
+
data.tar.gz: 3ebf4a1a3323aee14470f4c5734661e6e4106ba1a0e5f06f5cc0368a547ea024c4adfb1dfce1e2c6ce18162fde79020d3cde7dc777b81bae1099564c5b6de568
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@ It turns this:
|
|
6
6
|
|
7
7
|
```ruby
|
8
8
|
class AddsTwo
|
9
|
+
def self.call(*args)
|
10
|
+
new(*args).add
|
11
|
+
end
|
12
|
+
|
9
13
|
attr_reader :number
|
10
14
|
protected :number
|
11
15
|
|
@@ -135,9 +139,9 @@ SumDigits2[123]
|
|
135
139
|
# => ArgumentError: wrong number of arguments (given 1, expected 3)
|
136
140
|
```
|
137
141
|
|
138
|
-
###
|
142
|
+
### Filters
|
139
143
|
|
140
|
-
|
144
|
+
Filters can be passed to the Functo constructor, for example to implement types or coercion. A filter can be anything which responds to `[]`.
|
141
145
|
|
142
146
|
```ruby
|
143
147
|
class ValidatesNumeric
|
@@ -192,6 +196,8 @@ AddsFour['4']
|
|
192
196
|
|
193
197
|
```
|
194
198
|
|
199
|
+
If you have multiple arguments and only want one of them to have a filter, you can use `Functo.pass` for a filter that just returns its input.
|
200
|
+
|
195
201
|
## Acknowledgements
|
196
202
|
|
197
203
|
Functo was inspired by these gems:
|
data/lib/functo/version.rb
CHANGED
data/lib/functo.rb
CHANGED