Sha256: b717805f84a58128168369dcb8182dd7839a21f2b62df84059bd63aa55946803
Contents?: true
Size: 700 Bytes
Versions: 1
Compression:
Stored size: 700 Bytes
Contents
module Skr class SequentialId < Skr::Model FUNCTION_NAME="#{Skr::Core.config.table_prefix}next_sequential_id" self.primary_key = 'name' locked_fields :name, :current_value def self.next_for( klass ) begin res=ActiveRecord::Base.connection.raw_connection.exec( "select #{FUNCTION_NAME}( $1 )", [ klass.to_s ] ) res.getvalue(0,0).to_i ensure res.clear if res end end def self.set_next( klass, value ) self.connection.raw_connection.exec( "update #{table_name} set current_value = $1 where name = $2", [ value, klass.to_s ] ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-core-0.2 | lib/skr/sequential_id.rb |