Class: Ruflet::Rails::Protocol::MobileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruflet/rails/protocol/mobile_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ MobileLoader

Returns a new instance of MobileLoader.



7
8
9
# File 'lib/ruflet/rails/protocol/mobile_loader.rb', line 7

def initialize(file_path)
  @file_path = file_path
end

Instance Method Details

#load!Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruflet/rails/protocol/mobile_loader.rb', line 11

def load!
  absolute = File.expand_path(@file_path)
  raise ArgumentError, "Mobile file not found: #{absolute}" unless File.file?(absolute)

  captured_entrypoint = nil
  interceptor = lambda do |entrypoint:, **_kwargs|
    captured_entrypoint = entrypoint
    :captured
  end

  Ruflet.with_run_interceptor(interceptor) do
    Kernel.load(absolute)
  end

  raise ArgumentError, "No Ruflet app boot found in #{absolute}. Expected MyApp.new.run" unless captured_entrypoint

  { entrypoint: captured_entrypoint }
end