Sha256: 6d622b32d017f531c7d612106a797b36a0b413c987ec158dd854fe87022ac028

Contents?: true

Size: 451 Bytes

Versions: 9

Compression:

Stored size: 451 Bytes

Contents

module Plucky
  module Normalizers
    class CriteriaHashKey
      # Public: Returns key normalized for Mongo
      #
      # key - The key to normalize
      #
      # Returns key as Symbol if possible, else key with no changes
      def call(key)
        key = key.to_sym       if key.respond_to?(:to_sym)
        return call(key.field) if key.respond_to?(:field)
        return :_id            if key == :id
        key
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
plucky-0.8.0 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.7.0 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.6 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.5 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.4 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.3 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.2 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.1 lib/plucky/normalizers/criteria_hash_key.rb
plucky-0.6.0 lib/plucky/normalizers/criteria_hash_key.rb