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.



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

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/praxis/bootloader_stages/file_loader.rb', line 6

def path
  @path
end

Instance Method Details

#callback_argsObject



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

def callback_args
  application.file_layout[*path]
end

#executeObject



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

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