Sha256: 4926757c6870adc496c100e80395429bbc0a99c55889fcb96eab2b158a6a8d12

Contents?: true

Size: 711 Bytes

Versions: 6

Compression:

Stored size: 711 Bytes

Contents

module FactoryBot
  class Decorator
    class ClassKeyHash < Decorator
      def [](key)
        @component[symbolized_key key]
      end

      def []=(key, value)
        @component[symbolized_key key] = value
      end

      def key?(key)
        @component.key? symbolized_key(key)
      end

      private

      def symbolized_key(key)
        if key.respond_to?(:to_sym)
          key.to_sym
        elsif FactoryBot.allow_class_lookup
          ActiveSupport::Deprecation.warn "Looking up factories by class is deprecated and will be removed in 5.0. Use symbols instead and set FactoryBot.allow_class_lookup = false", caller
          key.to_s.underscore.to_sym
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
factory_bot-4.11.1 lib/factory_bot/decorator/class_key_hash.rb
factory_bot-4.11.0 lib/factory_bot/decorator/class_key_hash.rb
factory_bot-4.10.0 lib/factory_bot/decorator/class_key_hash.rb
factory_bot-4.8.2 lib/factory_bot/decorator/class_key_hash.rb
factory_bot-1.0.1.alpha lib/factory_bot/decorator/class_key_hash.rb
factory_bot-1.0.0.alpha lib/factory_bot/decorator/class_key_hash.rb