fancy_to_proc 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d0d378fd1815f35453d06e44ca5012d21f55eb3
4
- data.tar.gz: 56e8b70b14b3a60e89894d2d6ceba931ebc3c52f
3
+ metadata.gz: e2e9f8ba404259416d9fb95f02c7512ccb94cd65
4
+ data.tar.gz: 23a91d26ea0d8074f16e4a273faa5a375862c1e6
5
5
  SHA512:
6
- metadata.gz: 793358d118d5927f34d63ad7be85dc1bf343e257395c63f228e9e1926456dea1df19e2256129f124e7e9243083e50afad6efb602152a5584d0739fd7521642ad
7
- data.tar.gz: 9ad1da09a2d5eea8a373b0fa211fb30e07df71b19dda82b63d2d5de19c088ce90a3f329eca874257a20dc0be194ba55c6c6a3ad11d0e5509c10341143f7e0ae8
6
+ metadata.gz: 2df9d1cdbe3381826f2017dae3d5556a57e42777df7d5a036fa7bbcc23c9a777bfe7bfc978366c3c1f073e5225612805a560c3568b3e50afd6a46d206f5d44dd
7
+ data.tar.gz: a801aefaa530c52fa47cb99b79c7cfa25630faa6cb733331e803525f19f1af2f62cb409e46caf458997e1ac83f7ab0d7ef6d1a56a3bbe5e28317eac3f33dab42
data/README.md CHANGED
@@ -33,17 +33,7 @@ Yep, pass whatever arguments you like to your symbol method, very convenient!
33
33
  #=> ["banana", "haddock!"]
34
34
  ```
35
35
 
36
- Note the dot before the brackets, it's short for `.call()` which you can also use.
37
-
38
-
39
- ### [] with arguments
40
-
41
- This is just an alternate syntax for the above `call` option, specifically designed to make enumerable indexing a little nicer:
42
-
43
- ```ruby
44
- [{ thing: "banana" }, { thing: "hammock!" }].map &:[][:thing]
45
- #=> ["banana", "hammock!"]
46
- ```
36
+ Note the dot before the brackets; it's short for `.call()` which you can also use. Unlike in Proc we can't use square brackets for a call alias `[]` as this is used by Symbol for element referencing already.
47
37
 
48
38
 
49
39
  ### ~ method tilde
@@ -1,3 +1,3 @@
1
1
  module FancyToProc
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/fancy_to_proc.rb CHANGED
@@ -7,31 +7,27 @@ end
7
7
  class Symbol
8
8
  def ~
9
9
  method(self).to_proc
10
- end unless respond_to?(:~)
10
+ end unless method_defined?(:~)
11
11
 
12
12
  def |(other)
13
13
  proc { |*args| args.shift.__send__(self, other) }
14
- end unless respond_to?(:|)
14
+ end unless method_defined?(:|)
15
15
 
16
16
  def &(other)
17
17
  proc { |*args| other.to_proc.call to_proc.call(*args) }
18
- end unless respond_to?(:&)
18
+ end unless method_defined?(:&)
19
19
 
20
20
  def call(*defaults)
21
21
  proc { |*args| args.shift.__send__(self, *defaults) }
22
- end unless respond_to?(:call)
23
-
24
- def [](*defaults)
25
- call(*defaults)
26
- end unless respond_to?(:[])
22
+ end unless method_defined?(:call)
27
23
  end
28
24
 
29
25
  class Proc
30
26
  def |(other)
31
27
  curry(2)[other]
32
- end unless respond_to?(:|)
28
+ end unless method_defined?(:|)
33
29
 
34
30
  def &(other)
35
31
  proc { |*args| other.to_proc.call call(*args) }
36
- end unless respond_to?(:&)
32
+ end unless method_defined?(:&)
37
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_to_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon George
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-15 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler