Sha256: 939acb83132c5fe0e3f93e53d038da46121d34373de75bb01cc7fc6308bdb006

Contents?: true

Size: 560 Bytes

Versions: 46

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

class ReeDao::ExtractChanges
  include Ree::FnDSL

  fn :extract_changes do
    link :dao_cache, as: :__ree_dao_cache
  end

  contract(Symbol, Any, Hash => Hash)
  def call(table_name, primary_key, hash)
    cached = __ree_dao_cache.get(table_name, primary_key)
    return hash unless cached
    changes = {}

    hash.each do |column, value|
      previous_column_value = cached[column]

      if cached.has_key?(column) && previous_column_value != value
        changes[column] = value
      end
    end

    changes
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
ree_lib-1.0.48 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
ree_lib-1.0.47 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
ree_lib-1.0.46 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
ree_lib-1.0.45 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
ree_lib-1.0.44 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
ree_lib-1.0.43 lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb