Sha256: adbaf3fbfa46683b8e93493e0ef1dcbed0981d4432555b0f0359c984032b4bb2

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 Bytes

Contents

# frozen_string_literal: true

module LunaPark
  module Extensions
    module Repositories
      module Postgres
        module Update
          def save(input)
            entity = wrap(input)

            entity.updated_at = Time.now if entity.respond_to?(:updated_at)

            row       = to_row(entity)
            new_row   = dataset.where(primary_key => row[primary_key]).returning.update(row).first
            new_attrs = from_row(new_row)

            entity.set_attributes(new_attrs)
            entity
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
luna_park-0.13.0 lib/luna_park/extensions/repositories/postgres/update.rb