Sha256: eb7fa70c449c0b2d089fc0e2a475f2debbb04de2b4be9285262e532b78fae3d7
Contents?: true
Size: 741 Bytes
Versions: 2
Compression:
Stored size: 741 Bytes
Contents
class Db::Sync::Model < ActiveRecord::Base @abstract_class = true self.inheritance_column = nil def unique_data attributes.slice(*self.class.pkey) end def compare_unique_data(other) self.class.pkey.each do |key| attributes[key] <=> other[key] end end def self.include_id? attribute_names.include?('id') end def self.pkey if include_id? ['id'] else attribute_names.sort end end def self.ordered_attributes pkey + (attribute_names - pkey).sort end def self.records attributes_order = ordered_attributes order(pkey).map do |record| res = {} attributes_order.each do |key| res[key] = record[key] end res end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
db-sync-0.0.15 | lib/db/sync/model.rb |
db-sync-0.0.14 | lib/db/sync/model.rb |