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-4.0.4 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.3 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.1 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0pre6 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0pre5 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0pre3 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0pre2 lib/picky/query/qualifier_category_mapper.rb
picky-4.0.0pre1 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.16 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.15 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.14 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.13 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.12 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.11 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.10 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.9 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.8 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.7 lib/picky/query/qualifier_category_mapper.rb
picky-3.6.6 lib/picky/query/qualifier_category_mapper.rb