lib/rbbt/persist.rb in rbbt-util-5.5.59 vs lib/rbbt/persist.rb in rbbt-util-5.5.60

- old
+ new

@@ -52,13 +52,13 @@ return persistence_file unless persistence_file.nil? prefix = Misc.process_options persist_options, :prefix if prefix.nil? - perfile = file.gsub(/\//, '>') + perfile = file.to_s.gsub(/\//, '>') else - perfile = prefix.to_s + ":" + file.gsub(/\//, '>') + perfile = prefix.to_s + ":" + file.to_s.gsub(/\//, '>') end if options.include? :filters options[:filters].each do |match,value| perfile = perfile + "&F[#{match}=#{Misc.digest(value.inspect)}]" @@ -288,9 +288,17 @@ end else yield end + end + + def self.memory(name, options = {}, &block) + file = name + file << "_" << Misc.hash2md5(options) if options.any? + options = Misc.add_defaults options, :persist => true, :file => file + + persist name, :memory, options, &block end end module LocalPersist