Sha256: 6258edf53e889dae5fa2f22d88aca4721ff9a4aa323face179a684b87af80019

Contents?: true

Size: 487 Bytes

Versions: 9

Compression:

Stored size: 487 Bytes

Contents

module FactoryBot
  # @api private
  class NullObject < ::BasicObject
    def initialize(methods_to_respond_to)
      @methods_to_respond_to = methods_to_respond_to.map(&:to_s)
    end

    def method_missing(name, *args, &block)
      if respond_to?(name)
        nil
      else
        super
      end
    end

    def respond_to?(method, _include_private = false)
      @methods_to_respond_to.include? method.to_s
    end

    def respond_to_missing?(*)
      false
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
factory_bot-5.2.0 lib/factory_bot/null_object.rb
factory_bot-5.1.2 lib/factory_bot/null_object.rb
factory_bot-5.1.1 lib/factory_bot/null_object.rb
factory_bot-5.1.0 lib/factory_bot/null_object.rb
factory_bot-5.0.2 lib/factory_bot/null_object.rb
factory_bot-5.0.1 lib/factory_bot/null_object.rb
factory_bot-5.0.0 lib/factory_bot/null_object.rb
factory_bot-5.0.0.rc2 lib/factory_bot/null_object.rb
factory_bot-5.0.0.rc1 lib/factory_bot/null_object.rb