Class: CypressDev::SmartFactoryWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/cypress_dev/smart_factory_wrapper.rb

Defined Under Namespace

Modules: FactoryCleaner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files:, factory:, always_reload: false, factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File) ⇒ SmartFactoryWrapper



36
37
38
39
40
41
42
43
44
45
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 36

def initialize(files:, factory:, always_reload: false,
               factory_cleaner: FactoryCleaner, kernel: Kernel, file_system: File)
  self.files = files
  self.factory = factory
  self.always_reload = always_reload
  @kernel = kernel
  @file_system = file_system
  @factory_cleaner = factory_cleaner
  @latest_mtime = nil
end

Instance Attribute Details

#always_reloadObject

Returns the value of attribute always_reload.



34
35
36
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 34

def always_reload
  @always_reload
end

#factoryObject

Returns the value of attribute factory.



33
34
35
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 33

def factory
  @factory
end

#filesArray



32
33
34
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 32

def files
  @files
end

Class Method Details

.configure(files:, factory:, always_reload: true) ⇒ Object



19
20
21
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 19

def self.configure(files:, factory:, always_reload: true)
  @instance = new(files: files, factory: factory, always_reload: always_reload)
end

.create(*args) ⇒ Object



23
24
25
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 23

def self.create(*args)
  instance.create(*args)
end

.create_list(*args) ⇒ Object



27
28
29
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 27

def self.create_list(*args)
  instance.create_list(*args)
end

.instanceObject



15
16
17
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 15

def self.instance
  @instance ||= new(files: [], factory: SimpleRailsFactory)
end

Instance Method Details

#create(*args) ⇒ Object



47
48
49
50
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 47

def create(*args)
  load_files
  factory.create(*args)
end

#create_list(*args) ⇒ Object



52
53
54
55
# File 'lib/cypress_dev/smart_factory_wrapper.rb', line 52

def create_list(*args)
  load_files
  factory.create_list(*args)
end