Class: FactoryBot::NullObject Private

Inherits:
BasicObject
Defined in:
lib/factory_bot/null_object.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(methods_to_respond_to) ⇒ NullObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NullObject.



4
5
6
# File 'lib/factory_bot/null_object.rb', line 4

def initialize(methods_to_respond_to)
  @methods_to_respond_to = methods_to_respond_to.map(&:to_s)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Style/MissingRespondToMissing



8
9
10
11
12
13
14
# File 'lib/factory_bot/null_object.rb', line 8

def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing
  if respond_to?(name)
    nil
  else
    super
  end
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


16
17
18
# File 'lib/factory_bot/null_object.rb', line 16

def respond_to?(method)
  @methods_to_respond_to.include? method.to_s
end