Class: FactoryGirl::NullObject Private

Inherits:
BasicObject
Defined in:
lib/factory_girl/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_girl/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.



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

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

Instance Method Details

#respond_to?(method, include_private = false) ⇒ 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_girl/null_object.rb', line 16

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

#respond_to_missing?(*args) ⇒ 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)


20
21
22
# File 'lib/factory_girl/null_object.rb', line 20

def respond_to_missing?(*args)
  false
end