Sha256: 3a5a993333e684d5e6db4e64449d9949a3d523aa3ca8494e158de3e16d0921d1

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module Koine
  module Repository
    module IdAwareEntity
      def find(id)
        data = storage.find_one_by(id: id)
        return data unless data
        entity = new_entity
        hydrate(data, entity)
        entity
      end

      def create(entity)
        values = hydrator.extract(entity)
        values.delete("id")
        values.delete(:id)
        entity.id = storage.insert(values)
      end

      def update(entity)
        values = hydrator.extract(entity)
        values.delete(:id)
        storage.update_where({ id: entity.id }, values)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koine-repository-0.9.0 lib/koine/repository/id_aware_entity.rb