Sha256: a47465519fb6d939802961b0eced5500ebd53c89d7587cc15e930a925828bf51

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

module Dynflow
  module CoordinatorAdapters
    class Sequel < Abstract
      def initialize(world)
        super
        @sequel_adapter = world.persistence.adapter
        Type! @sequel_adapter, PersistenceAdapters::Sequel
      end

      def create_record(record)
        @sequel_adapter.insert_coordinator_record(record.to_hash)
      rescue Errors::PersistenceError => e
        if e.cause.is_a? ::Sequel::UniqueConstraintViolation
          raise Coordinator::DuplicateRecordError.new(record)
        else
          raise e
        end
      end

      def update_record(record)
        @sequel_adapter.update_coordinator_record(record.class.name, record.id, record.to_hash)
      end

      def delete_record(record)
        @sequel_adapter.delete_coordinator_record(record.class.name, record.id)
      end

      def find_records(filter_options)
        @sequel_adapter.find_coordinator_records(filters: filter_options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynflow-1.1.2 lib/dynflow/coordinator_adapters/sequel.rb
dynflow-1.1.1 lib/dynflow/coordinator_adapters/sequel.rb