Commit d7bae1a

mo khan <mo@mokhan.ca>
2014-07-13 15:33:38
move to proper namespace.
1 parent b820d32
lib/humble/column.rb
@@ -76,7 +76,7 @@ module Humble
 
     def apply(row, entity, session)
       puts "#{@attribute} #{@type} #{row} #{entity}"
-      items = session.find_all(@type).to_a
+      items = session.find_all(@type)
       entity.public_send("#{@attribute}=", items)
     end
 
lib/humble/default_mapper.rb
@@ -1,15 +1,17 @@
-class DefaultMapper
-  attr_reader :session, :table
+module Humble
+  class DefaultMapper
+    attr_reader :session, :table
 
-  def initialize(table, session)
-    @table = table
-    @session = session
-  end
+    def initialize(table, session)
+      @table = table
+      @session = session
+    end
 
-  def map_from(row)
-    table.type.new.tap do |entity|
-      table.each do |column|
-        column.apply(row, entity, session)
+    def map_from(row)
+      table.type.new.tap do |entity|
+        table.each do |column|
+          column.apply(row, entity, session)
+        end
       end
     end
   end
lib/humble/identity_map.rb
@@ -1,14 +1,16 @@
-class IdentityMap
-  def initialize(items = {})
-    @items = items
-  end
+module Humble
+  class IdentityMap
+    def initialize(items = {})
+      @items = items
+    end
 
-  def fetch(key, &block)
-    if @items.key?(key)
-      @items[key]
-    else
-      @items[key] = block.call
-      @items[key]
+    def fetch(key, &block)
+      if @items.key?(key)
+        @items[key]
+      else
+        @items[key] = block.call
+        @items[key]
+      end
     end
   end
 end
lib/humble/result_set.rb
@@ -28,7 +28,7 @@ module Humble
     def items
       @items ||= @rows.map do |row|
         @mapper.map_from(row)
-      end.to_a
+      end
     end
   end
 end