Sha256: 96905ea49a74a9459a3720dd488a5c1145a34013d31c50d3e3ae78b1465993ba
Contents?: true
Size: 1.29 KB
Versions: 21
Compression:
Stored size: 1.29 KB
Contents
require 'json' module FlydataCore module Oracle class SourcePos include Comparable # Source Position data for Oracle # # Use system change number (SCN) for managing a consitent check point in # Oracle database. SCN is a unsigned integer value. def initialize(scn_or_obj, pk_values = nil) if scn_or_obj.kind_of?(self.class) scn_or_obj.tap do |s| @scn = s.scn @pk_values = s.pk_values end else @scn = scn_or_obj.to_i if scn_or_obj @pk_values = pk_values # must be array or nil end end attr_reader :scn attr_reader :pk_values def empty? @scn.to_s.empty? end def to_s pk_values = @pk_values ? @pk_values.to_json : '' "#{@scn}\t#{pk_values}" end def <=>(other) if @scn != other.scn return @scn <=> other.scn elsif @pk_values.nil? && !other.pk_values.nil? 1 elsif !@pk_values.nil? && other.pk_values.nil? -1 elsif @pk_values == other.pk_values 0 else @pk_values.to_s <=> other.pk_values.to_s end end def self.load(str) scn, pk_values = str.split("\t").collect{|v| v.strip} pk_values = if pk_values.to_s.empty? nil else JSON.parse(pk_values) end self.new(scn, pk_values) end end end end
Version data entries
21 entries across 21 versions & 1 rubygems