2017-10-20 15:20:28 -04:00
|
|
|
module FactoryBot
|
2012-05-05 02:31:31 -04:00
|
|
|
# @api private
|
2012-03-09 16:14:06 -05:00
|
|
|
class NullObject < ::BasicObject
|
2012-04-19 21:34:47 -04:00
|
|
|
def initialize(methods_to_respond_to)
|
|
|
|
@methods_to_respond_to = methods_to_respond_to.map(&:to_s)
|
|
|
|
end
|
|
|
|
|
2020-05-31 15:53:03 -04:00
|
|
|
def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing
|
2012-04-19 21:34:47 -04:00
|
|
|
if respond_to?(name)
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-31 16:13:12 -04:00
|
|
|
def respond_to?(method)
|
2012-04-19 21:34:47 -04:00
|
|
|
@methods_to_respond_to.include? method.to_s
|
2012-01-08 00:23:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|