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
|
|
|
|
|
|
|
|
def method_missing(name, *args, &block)
|
|
|
|
if respond_to?(name)
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-05 14:54:08 -04:00
|
|
|
def respond_to?(method, _include_private = false)
|
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
|
2012-07-27 10:14:57 -04:00
|
|
|
|
2018-10-05 14:54:08 -04:00
|
|
|
def respond_to_missing?(*)
|
2012-07-27 10:14:57 -04:00
|
|
|
false
|
|
|
|
end
|
2012-01-08 00:23:25 -05:00
|
|
|
end
|
|
|
|
end
|