Sha256: a58bbcc03485a6fce6711cb5920aedb4323b698604cfd224077b6299590c9223

Contents?: true

Size: 972 Bytes

Versions: 13

Compression:

Stored size: 972 Bytes

Contents

module ActiveEnum
  module Storage
    autoload :MemoryStore, "active_enum/storage/memory_store"
    autoload :I18nStore, "active_enum/storage/i18n_store"

    class NotImplemented < StandardError; end

    class AbstractStore 
      def initialize(enum_class, order, options={})
        @enum, @order, @options = enum_class, order, options
      end

      def set(id, name, meta=nil)
        raise NotImplemented
      end

      def get_by_id(id)
        raise NotImplemented
      end

      def get_by_name(name)
        raise NotImplemented
      end

      def check_duplicate(id, name)
        if get_by_id(id) 
          raise ActiveEnum::DuplicateValue, "#{@enum}: Duplicate id #{id}"
        elsif get_by_name(name)
          raise ActiveEnum::DuplicateValue, "#{@enum}: Duplicate name '#{name}'"
        end
      end

      def values
        _values
      end

      private
      
      def _values
        raise NotImplemented
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_enum-1.2.1 lib/active_enum/storage/abstract_store.rb
active_enum-1.2.0 lib/active_enum/storage/abstract_store.rb
active_enum-1.1.0 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc8 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc7 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc6 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc5 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc4 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc3 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc2 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.rc1 lib/active_enum/storage/abstract_store.rb
active_enum-1.0.0.pre lib/active_enum/storage/abstract_store.rb