Class: FactoryBot::Evaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_bot/evaluation.rb

Instance Method Summary collapse

Constructor Details

#initialize(evaluator, attribute_assigner, to_create, observer) ⇒ Evaluation

Returns a new instance of Evaluation.



3
4
5
6
7
8
# File 'lib/factory_bot/evaluation.rb', line 3

def initialize(evaluator, attribute_assigner, to_create, observer)
  @evaluator = evaluator
  @attribute_assigner = attribute_assigner
  @to_create = to_create
  @observer = observer
end

Instance Method Details

#create(result_instance) ⇒ Object



12
13
14
15
16
17
# File 'lib/factory_bot/evaluation.rb', line 12

def create(result_instance)
  case @to_create.arity
  when 2 then @to_create[result_instance, @evaluator]
  else @to_create[result_instance]
  end
end

#notify(name, result_instance) ⇒ Object



19
20
21
# File 'lib/factory_bot/evaluation.rb', line 19

def notify(name, result_instance)
  @observer.update(name, result_instance)
end