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

24 lines
498 B
Ruby
Raw Normal View History

2012-05-05 01:14:21 -04:00
require 'observer'
module FactoryGirl
class Evaluation
include Observable
def initialize(attribute_assigner, to_create)
@attribute_assigner = attribute_assigner
@to_create = to_create || ->(instance) { instance.save! }
end
2012-05-05 01:14:21 -04:00
delegate :object, :hash, to: :@attribute_assigner
def create(result_instance)
@to_create[result_instance]
end
def notify(name, result_instance)
changed
notify_observers(name, result_instance)
end
end
end