Sha256: 6ad70517addd5c7d5a20749d5a3412f05a659bc16a3b18e9709f1fa2b7f99237

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

require_relative "key_vortex/version"

class KeyVortex
  class Error < StandardError; end

  def initialize(adapter, record_class)
    @adapter = adapter
    @record_class = record_class

    record_class.fields.each do |field|
      next unless field.prohibited_by?(adapter)

      raise KeyVortex::Error,
            "#{adapter.class} can only handle field #{field.name} with these limitations:\n" +
            adapter.limitation_for(field).to_s +
            "\n\nThe following record violates these limitations:\n#{field.limitation}"
    end
  end

  def save(record)
    @adapter.save(record)
  end

  def find(id)
    @adapter.find(id)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
key-vortex-0.1.4 lib/key_vortex.rb
key-vortex-0.1.3 lib/key_vortex.rb