Class: FactoryBot::With::Scoped

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

Overview

An internal class to implement implicit context scope.

Class Method Summary collapse

Class Method Details

.with_ancestors(ancestors) ⇒ Object

Parameters:

  • ancestors (Array<Array(AssocInfo, Object)>)


13
14
15
16
17
18
19
# File 'lib/factory_bot/with/scoped.rb', line 13

def with_ancestors(ancestors, &)
  tmp_ancestors = self.ancestors
  Thread.current[:factory_bot_with_scoped_ancestors] = [*ancestors, *tmp_ancestors || []]
  yield
ensure
  Thread.current[:factory_bot_with_scoped_ancestors] = tmp_ancestors
end