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, dir_system: Dir) ⇒ SmartFactoryWrapper

Returns a new instance of SmartFactoryWrapper.



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

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

Instance Attribute Details

#always_reloadObject

Returns the value of attribute always_reload.



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

def always_reload
  @always_reload
end

#factoryArray

Returns:

  • (Array)


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

def factory
  @factory
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



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

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

#create_list(*args) ⇒ Object



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

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