Permalink
Browse files

adding model streamer -- creates gorillib/model from hash

  • Loading branch information...
1 parent e9990ba commit f57020cc1e8b0c4499c9fc6c5b38d191d4bc894b Philip (flip) Kromer committed Aug 12, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/wukong/streamer/model_streamer.rb
View
20 lib/wukong/streamer/model_streamer.rb
@@ -0,0 +1,20 @@
+module Wukong
+ module Streamer
+ class ModelStreamer < Wukong::Streamer::Base
+ class_attribute :model_klass
+
+ def initialize
+ self.model_klass = self.class.model_klass
+ end
+
+ #
+ # Default recordizer: returns array of fields by splitting at tabs
+ #
+ def recordize line
+ vals = line.split("\t")
+ [@model_klass.from_tuple(*vals)]
+ end
+
+ end
+ end
+end

0 comments on commit f57020c

Please sign in to comment.