Sha256: 9afac660ffdb8c81da805dfb4117002e6b17743cba665726740306caf165c727

Contents?: true

Size: 451 Bytes

Versions: 3

Compression:

Stored size: 451 Bytes

Contents

module Jamnagar
  module Storage
    class ItemStore < BasicStore

      class MissingPrimaryKeyException < StandardError;end

      def insert(item)
        return unless item
        raise MissingPrimaryKeyException unless has_primary_key?(item)
        super item
      end

    private
      def has_primary_key?(item)
        return false unless item
        return false unless item.keys.include?("_id")
        true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jamnagar-1.3.9.1 lib/jamnagar/storage/item_store.rb
jamnagar-1.3.9 lib/jamnagar/storage/item_store.rb
jamnagar-1.3.8 lib/jamnagar/storage/item_store.rb