Sha256: 4ecfae67cc361a45e863a327593c5c02276e7f70c8cc4bdc6e7a8cb0701b95b7

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

module Internals

  module Indexed
  
    #
    #
    class Index
    
      attr_reader :name, :result_identifier, :combinator, :categories
    
      delegate :load_from_cache,
               :to => :categories
    
      # TODO Externalize?
      #
      def initialize name, options = {}
        @name                     = name
      
        @result_identifier        = options[:result_identifier] || name
        @bundle_class             = options[:indexed_bundle_class] # TODO This should actually be a fixed parameter.
        ignore_unassigned_tokens  = options[:ignore_unassigned_tokens] || false # TODO Move to query, somehow.
      
        @categories = Categories.new ignore_unassigned_tokens: ignore_unassigned_tokens
      end
    
      # TODO Doc. Externalize?
      #
      def define_category category_name, options = {}
        options = default_category_options.merge options
      
        new_category = Category.new category_name, self, options
        categories << new_category
        new_category
      end
    
      # By default, the category uses
      # * the index's bundle type.
      #
      def default_category_options
        {
          :indexed_bundle_class => @bundle_class
        }
      end
    
      # Return the possible combinations for this token.
      #
      # A combination is a tuple <token, index_bundle>.
      #
      def possible_combinations token
        categories.possible_combinations_for token
      end
    
    end
  
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picky-1.5.2 lib/picky/internals/indexed/index.rb
picky-1.5.1 lib/picky/internals/indexed/index.rb
picky-1.5.0 lib/picky/internals/indexed/index.rb
picky-1.4.3 lib/picky/internals/indexed/index.rb
picky-1.4.2 lib/picky/internals/indexed/index.rb