Commits

Kaspar Schiess  committed fd6f453

Refactoring into different files

  • Participants
  • Parent commits 257d523

Comments (0)

Files changed (3)

File lib/par/result.rb

     def self.top
       @top ||= Top.new
     end
-
-    class Bottom
-      def >> other
-        self
-      end
-      def maybe
-        Par.top
-      end
-      def bottom?
-        true
-      end
-      def as obj=nil, &block
-        self
-      end
-    end
-
-    class Top
-      def >> other
-        other
-      end
-      def maybe
-        self
-      end
-      def bottom?
-        false
-      end
-      def as obj=nil, &block
-        unless block_given?
-          return Result.new(obj)
-        end
-        return Result.new(block.call(self))
-      end
-    end
   end
 end
+
+require 'par/result/top'
+require 'par/result/bottom'

File lib/par/result/bottom.rb

+module Par
+  class Bottom
+    def >> other
+      self
+    end
+    def maybe
+      Par.top
+    end
+    def bottom?
+      true
+    end
+    def as obj=nil, &block
+      self
+    end
+  end
+end

File lib/par/result/top.rb

+module Par
+  class Top
+    def >> other
+      other
+    end
+    def maybe
+      self
+    end
+    def bottom?
+      false
+    end
+    def as obj=nil, &block
+      unless block_given?
+        return Result.new(obj)
+      end
+      return Result.new(block.call(self))
+    end
+  end
+end