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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2083fd9241f81ae8e66afd0db7f287b11c2fc56c
4
- data.tar.gz: 66a47b6423663ec128fc2420c70dc47031503bf7
3
+ metadata.gz: edec39c1333fdfbe36d34afdb69a8f58bb5dfb9c
4
+ data.tar.gz: 14f56acf9d721fdd4b16f169466fe022fa98df20
5
5
  SHA512:
6
- metadata.gz: 54c9d97f8a56098aff7e9fa499e5643ffe3e8e095f942d193e13731118d082de0f69dedc39a25b4c907e0a908d852b3e8fbcb9fe33ccfbfbc8eb35c720b26386
7
- data.tar.gz: 94dc2a1e06f415cf1a49dc5b762e95848d0c4a8299bed7bbef6c2da07ceb08263c253a3bb1dd1a0c8ad4b70e8ad46a79381ed51e0af2e245c4c690fd4291de6b
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
- ### Types
142
+ ### Filters
139
143
 
140
- Types and coercion are not built in to Functo but they can be achieved by passing anything that responds to `[]` to the constructor.
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:
@@ -1,3 +1,3 @@
1
1
  class Functo < Module
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/functo.rb CHANGED
@@ -5,6 +5,10 @@ class Functo < Module
5
5
 
6
6
  private_class_method :new
7
7
 
8
+ def self.pass
9
+ Proc.new { |obj| obj }
10
+ end
11
+
8
12
  def self.call(*names)
9
13
  output = names.shift
10
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: functo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Scully