Sha256: 61f8d8d24f1a03351189ec5d54a159d14453c519c502b46077f23f91068ee316

Contents?: true

Size: 884 Bytes

Versions: 30

Compression:

Stored size: 884 Bytes

Contents

module Picky

  # coding: utf-8
  #
  module Query

    # Collection class for qualifiers.
    #
    class QualifierCategoryMapper # :nodoc:all

      attr_reader :mapping

      #
      #
      def initialize
        @mapping = {}
      end

      #
      #
      def add category
        category.qualifiers.each do |qualifier|
          sym_qualifier = qualifier.intern
          warn %Q{Warning: Qualifier "#{qualifier}" already mapped to category #{mapping[sym_qualifier].identifier} (ambiguous qualifier mapping).} if mapping.has_key? sym_qualifier
          mapping[sym_qualifier] = category
        end
      end

      # Normalizes the given qualifier.
      #
      # Returns nil if it is not allowed, the normalized qualifier if it is.
      #
      def map qualifier
        return nil if qualifier.empty?

        @mapping[qualifier.intern]
      end

    end

  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-3.6.4 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.3 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.2 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.1 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.0 lib/picky/query/qualifier_category_mapper.rb
picky-3.5.4 lib/picky/query/qualifier_category_mapper.rb
picky-3.5.3 lib/picky/query/qualifier_category_mapper.rb
picky-3.5.2 lib/picky/query/qualifier_category_mapper.rb
picky-3.5.1 lib/picky/query/qualifier_category_mapper.rb
picky-3.5.0 lib/picky/query/qualifier_category_mapper.rb