Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Now that this is growing, split the Present and Blank classes into se…

…parate files.
  • Loading branch information...
commit ef687c3b20a4286ee2485d52c51db41e4a48de93 1 parent c1ae4a2
@mike-burns mike-burns authored
View
40 lib/wrapped/blank.rb
@@ -0,0 +1,40 @@
+class Blank
+ include Enumerable
+
+ def unwrap
+ raise IndexError.new("Blank has no value")
+ end
+
+ def unwrap_or(default)
+ default
+ end
+
+ def present
+ self
+ end
+
+ def blank(&block)
+ block.call
+ self
+ end
+
+ def each
+ []
+ end
+
+ def present?
+ false
+ end
+
+ def blank?
+ true
+ end
+
+ def try
+ self
+ end
+
+ def fmap
+ self
+ end
+end
View
3  lib/wrapped/injection.rb
@@ -1,4 +1,5 @@
-require 'wrapped/types'
+require 'wrapped/present'
+require 'wrapped/blank'
class Object
def wrapped
View
41 lib/wrapped/types.rb → lib/wrapped/present.rb
@@ -47,44 +47,3 @@ def fmap
(yield unwrap).wrapped
end
end
-
-class Blank
- include Enumerable
-
- def unwrap
- raise IndexError.new("Blank has no value")
- end
-
- def unwrap_or(default)
- default
- end
-
- def present
- self
- end
-
- def blank(&block)
- block.call
- self
- end
-
- def each
- []
- end
-
- def present?
- false
- end
-
- def blank?
- true
- end
-
- def try
- self
- end
-
- def fmap
- self
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.