Sha256: c60e18907f05ae99c91c6c9282f3613b63fb6747f394cfa7a618ffabd5f0015b

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

class Db::Sync::Model < ActiveRecord::Base
  @abstract_class = true

  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.records
    order(pkey)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
db-sync-0.0.4 lib/db/sync/model.rb