ronad 0.6.1 → 0.7.0
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/lib/ronad/monad.rb +9 -11
- data/lib/ronad/version.rb +1 -1
- 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: b5dcb8f23c03e79aa05ea674e652e6706b100a2e
|
4
|
+
data.tar.gz: bb397e667d3d0aabd547b03144e07ab9bb613348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 545731ce0d8b81434fbe3480642f003c1e0f35386dd641e356fffea71138c104d1f4d54ad719f359b082d52ec7703854ea6a04a78b04e7c2de614e901ca81a40
|
7
|
+
data.tar.gz: 7f9f56a92c6d853faf228f66a1b3ae3a4b926bc8990ea81b5c971d56ec9b084af94bdb47aa74e437e144fc054f8f2c8789d955e0aecec192e9cdc8d32601a990
|
data/lib/ronad/monad.rb
CHANGED
@@ -3,6 +3,13 @@ module Ronad
|
|
3
3
|
#
|
4
4
|
# @abstract
|
5
5
|
class Monad
|
6
|
+
(Object.new.methods - [:class]).each do |object_method|
|
7
|
+
define_method object_method do |*args|
|
8
|
+
and_then { |v| v.public_send(object_method, *args) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
6
13
|
def initialize(value)
|
7
14
|
if Monad === value
|
8
15
|
@value = value.value
|
@@ -11,6 +18,7 @@ module Ronad
|
|
11
18
|
end
|
12
19
|
end
|
13
20
|
|
21
|
+
|
14
22
|
# Extract the value from the monad. If the underlying value responds to
|
15
23
|
# #value then this will be bypassed instead.
|
16
24
|
#
|
@@ -43,6 +51,7 @@ module Ronad
|
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
54
|
+
|
46
55
|
# Alias for #monad_value
|
47
56
|
#
|
48
57
|
# @see #monad_value
|
@@ -51,15 +60,6 @@ module Ronad
|
|
51
60
|
end
|
52
61
|
|
53
62
|
|
54
|
-
# Proxy all Object methods to underlying value
|
55
|
-
#
|
56
|
-
# @private
|
57
|
-
Object.new.methods.each do |object_method|
|
58
|
-
define_method object_method do |*args|
|
59
|
-
and_then { |v| v.public_send(object_method, *args) }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
63
|
private
|
64
64
|
|
65
65
|
# Provides convinience for chaining methods together while maintaining a
|
@@ -84,8 +84,6 @@ module Ronad
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
and_then { |value| value.public_send(method, *unwrapped_args, &block) }
|
87
|
-
rescue TypeError
|
88
|
-
self.class.new(nil)
|
89
87
|
end
|
90
88
|
|
91
89
|
def respond_to_missing?(method_name, include_private = false)
|
data/lib/ronad/version.rb
CHANGED