lib/openwfe/storage/yamlfilestorage.rb in openwferu-0.9.5 vs lib/openwfe/storage/yamlfilestorage.rb in openwferu-0.9.6

- old
+ new

@@ -84,24 +84,21 @@ # # Stores an object with its FlowExpressionId instance as its key. # def []= (fei, object) synchronize do + fei_path = compute_file_path(fei) fei_parent_path = File.dirname(fei_path) FileUtils.makedirs(fei_parent_path) \ - if not File.exist?(fei_parent_path) - - fd = IO.sysopen(fei_path , "w+") - io = IO.open(fd , "w+") - - data = YAML.dump(object) - - io.write(data) - io.close + unless File.exist?(fei_parent_path) + + File.open(fei_path, "w") do |file| + YAML.dump(object, file) + end end end # # Deletes the whole storage directory... beware... @@ -162,17 +159,18 @@ protected def load_object (path) - data = IO.read(path) - object = YAML.load(data) + #data = IO.read(path) + #object = YAML.load(data) + object = YAML.load_file(path) object.application_context = @application_context \ if object.respond_to? :application_context= - return object + object end def count_objects count = 0 Find.find(@basepath) do |path| @@ -199,10 +197,9 @@ # # Passes each object to the given block # def each_object (&block) - return unless block each_object_path do |path| block.call load_object(path) end end