Class: Praxis::BootloaderStages::FileLoader

Inherits:
Stage
  • Object
show all
Defined in:
lib/praxis/bootloader_stages/file_loader.rb

Instance Attribute Summary collapse

Attributes inherited from Stage

#after_callbacks, #before_callbacks, #context, #name, #stages

Instance Method Summary collapse

Methods inherited from Stage

#after, #application, #before, #execute_callbacks, #run, #setup!, #setup_deferred_callbacks!

Constructor Details

#initialize(name, application, path: nil) ⇒ FileLoader

Returns a new instance of FileLoader.



10
11
12
13
# File 'lib/praxis/bootloader_stages/file_loader.rb', line 10

def initialize(name, application, path: nil)
  super
  @path = path || Array(name)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/praxis/bootloader_stages/file_loader.rb', line 8

def path
  @path
end

Instance Method Details

#callback_argsObject



24
25
26
# File 'lib/praxis/bootloader_stages/file_loader.rb', line 24

def callback_args
  application.file_layout[*path]
end

#executeObject



15
16
17
18
19
20
21
22
# File 'lib/praxis/bootloader_stages/file_loader.rb', line 15

def execute
  application.file_layout[*path].each do |file|
    next if application.loaded_files.include?(file)
    next unless file.extname == '.rb'
    require file
    application.loaded_files << file
  end
end