Class: FactoryGirl::NullObject

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

Instance Method Summary collapse

Constructor Details

#initialize(methods_to_respond_to) ⇒ NullObject

Returns a new instance of NullObject.



3
4
5
# File 'lib/factory_girl/null_object.rb', line 3

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



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

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/factory_girl/null_object.rb', line 15

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