lib/cpee/persistence.rb in cpee-2.1.51 vs lib/cpee/persistence.rb in cpee-2.1.52

- old
+ new

@@ -17,10 +17,13 @@ module Persistence @@obj = 'instance' def self::obj #{{{ @@obj end #}}} + def self::obj=(it) #{{{ + @@obj = it + end #}}} def self::set_list(id,opts,item,values,deleted=[]) #{{{ ah = AttributesHelper.new attributes = Persistence::extract_list(id,opts,'attributes').to_h dataelements = Persistence::extract_list(id,opts,'dataelements').to_h @@ -79,9 +82,18 @@ opts[:redis].zrevrange(@@obj + 's',0,-1).each do |instance| yield instance end end + def self::new_object(opts) + id = opts[:redis].zrevrange(@@obj + 's', 0, 0).first.to_i + 1 + opts[:redis].zadd(@@obj + 's',id,id) + id + end + def self::new_static_object(id,opts) + opts[:redis].set(File.join(@@obj + ":#{id}",'state'),'') + nil + end def self::new_object(opts) id = opts[:redis].zrevrange(@@obj + 's', 0, 0).first.to_i + 1 opts[:redis].zadd(@@obj + 's',id,id) id end