Sha256: 89a4f99f75c894fee41e8d77355aa6efc4fb7f22e98eefaff1fe450d7a2d6b65

Contents?: true

Size: 1006 Bytes

Versions: 13

Compression:

Stored size: 1006 Bytes

Contents

module Relaton
  module Index
    #
    # Pool of indexes
    #
    class Pool
      def initialize
        @pool = {}
      end

      #
      # Return index by type, create if not exists
      #
      # @param [String] type <description>
      # @param [String, nil] url external URL to index, used to fetch index for searching files
      # @param [String, nil] file output file name
      # @param [Array<Symbol>, nil] id_keys keys to check if index is correct
      #
      # @return [Relaton::Index::Type] typed index
      #
      def type(type, **args)
        if @pool[type.upcase.to_sym]&.actual?(**args)
          @pool[type.upcase.to_sym]
        else
          @pool[type.upcase.to_sym] = Type.new(type, args[:url], args[:file], args[:id_keys])
        end
      end

      #
      # Remove index by type from pool
      #
      # @param [String] type index type
      #
      # @return [void]
      #
      def remove(type)
        @pool.delete type.upcase.to_sym
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
relaton-index-0.2.14 lib/relaton/index/pool.rb
relaton-index-0.2.13 lib/relaton/index/pool.rb
relaton-index-0.2.12 lib/relaton/index/pool.rb
relaton-index-0.2.11 lib/relaton/index/pool.rb
relaton-index-0.2.10 lib/relaton/index/pool.rb
relaton-index-0.2.9 lib/relaton/index/pool.rb
relaton-index-0.2.8 lib/relaton/index/pool.rb
relaton-index-0.2.7 lib/relaton/index/pool.rb
relaton-index-0.2.6 lib/relaton/index/pool.rb
relaton-index-0.2.5 lib/relaton/index/pool.rb
relaton-index-0.2.4 lib/relaton/index/pool.rb
relaton-index-0.2.3 lib/relaton/index/pool.rb
relaton-index-0.2.2 lib/relaton/index/pool.rb