1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_bot/null_object.rb

21 lines
457 B
Ruby
Raw Normal View History

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