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