Permalink
Browse files

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

…parate files.
  • Loading branch information...
1 parent c1ae4a2 commit ef687c3b20a4286ee2485d52c51db41e4a48de93 @mike-burns mike-burns committed Jul 29, 2011
Showing with 42 additions and 42 deletions.
  1. +40 −0 lib/wrapped/blank.rb
  2. +2 −1 lib/wrapped/injection.rb
  3. +0 −41 lib/wrapped/{types.rb → present.rb}
View
@@ -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
@@ -1,4 +1,5 @@
-require 'wrapped/types'
+require 'wrapped/present'
+require 'wrapped/blank'
class Object
def wrapped
@@ -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

0 comments on commit ef687c3

Please sign in to comment.