OSDN Git Service

import:change method name. retake test
[pettanr/pettanr.git] / vendor / plugins / pettan_importer / lib / pettan_importer.rb
index 3418ec2..931ebb3 100644 (file)
@@ -16,12 +16,12 @@ module ActiveRecord
           end
         end
         
-        def import(data, &blk)
+        def import_text(data, &blk)
           d = JSON.parse_no_except(data)
           return false unless d
           res = []
           self.transaction do
-            self.each_import(d) do |name, item|
+            d.each do |name, item|
               m = blk.call(name, item)
               res.push(m) unless m.valid?
             end
@@ -30,14 +30,14 @@ module ActiveRecord
           res
         end
         
-        def import_file(filename)
+        def import_file(filename, &blk)
           t = nil
           begin
             t = File.open(filename, 'r').read
           rescue
             return false
           end
-          self.import t
+          self.import_text t, &blk
         end
         
       end