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/evaluation.rb

28 lines
603 B
Ruby
Raw Normal View History

2012-05-05 01:14:21 -04:00
require 'observer'
module FactoryBot
class Evaluation
include Observable
2017-09-28 08:17:17 -04:00
def initialize(evaluator, attribute_assigner, to_create)
@evaluator = evaluator
@attribute_assigner = attribute_assigner
@to_create = to_create
end
2012-05-05 01:14:21 -04:00
delegate :object, :hash, to: :@attribute_assigner
def create(result_instance)
2017-09-28 08:17:17 -04:00
case @to_create.arity
when 2 then @to_create[result_instance, @evaluator]
else @to_create[result_instance]
end
end
def notify(name, result_instance)
changed
notify_observers(name, result_instance)
end
end
end