Sha256: 73b9364d5bceca5496125ce6e28f055cad48c2a0b0fcc8d57662bbf78a4618a7

Contents?: true

Size: 673 Bytes

Versions: 3

Compression:

Stored size: 673 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 if field.within?(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

3 entries across 3 versions & 1 rubygems

Version Path
key-vortex-0.2.2 lib/key_vortex.rb
key-vortex-0.2.1 lib/key_vortex.rb
key-vortex-0.2.0 lib/key_vortex.rb