ronad 0.6.1 → 0.7.0

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: 27221364a6e2771ea6db699787f391975b34b48c
4
- data.tar.gz: b0db52708179ee6f9520fe585412d5ec2bd70f8d
3
+ metadata.gz: b5dcb8f23c03e79aa05ea674e652e6706b100a2e
4
+ data.tar.gz: bb397e667d3d0aabd547b03144e07ab9bb613348
5
5
  SHA512:
6
- metadata.gz: b9be0c9bcd13d70e7d95b829f4e8c77f0bccdf4f672b8461498542c9d0a14f67ca6b7fc7b988cd40b7b83b6f6728c28f1dc870e4e196f01376945d5dbe883373
7
- data.tar.gz: 83e996862994b174cd470acdeecf61ad0ac08397fcf9cffb7f8f38ebedad98e40259cd158591f8025127b1f8c339fa1ceaccfb0a84196af4dc24d70d5dc1ce2d
6
+ metadata.gz: 545731ce0d8b81434fbe3480642f003c1e0f35386dd641e356fffea71138c104d1f4d54ad719f359b082d52ec7703854ea6a04a78b04e7c2de614e901ca81a40
7
+ data.tar.gz: 7f9f56a92c6d853faf228f66a1b3ae3a4b926bc8990ea81b5c971d56ec9b084af94bdb47aa74e437e144fc054f8f2c8789d955e0aecec192e9cdc8d32601a990
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Ronad
2
- VERSION = '0.6.1'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uri Gorelik