Sha256: 485292cf5bfa87ab4095b045b02a3eda0648a407c858762ea1b16d1c3bfcb478

Contents?: true

Size: 884 Bytes

Versions: 22

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.to_sym
          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.blank?

        @mapping[qualifier.to_sym]
      end

    end

  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
picky-3.2.0 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.13 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.12 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.11 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.10 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.9 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.8 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.7 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.6 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.5 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.4 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.3 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.2 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.1 lib/picky/query/qualifier_category_mapper.rb
picky-3.1.0 lib/picky/query/qualifier_category_mapper.rb
picky-3.0.1 lib/picky/query/qualifier_category_mapper.rb
picky-3.0.0 lib/picky/query/qualifier_category_mapper.rb
picky-3.0.0.pre5 lib/picky/query/qualifier_category_mapper.rb
picky-3.0.0.pre4 lib/picky/query/qualifier_category_mapper.rb
picky-3.0.0.pre3 lib/picky/query/qualifier_category_mapper.rb