Class: Ruflet::Rails::Protocol::Runner

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

Instance Method Summary collapse

Constructor Details

#initialize(&entrypoint) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(&entrypoint)
  @entrypoint = entrypoint
end

Instance Method Details

#build_app_endpoint(file_path:, path: nil) ⇒ Object Also known as: build_mobile_endpoint



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruflet/rails/protocol/runner.rb', line 17

def build_app_endpoint(file_path:, path: nil)
  absolute = File.expand_path(file_path)
  entrypoint = lambda do |page, env|
    loaded = MobileLoader.new(absolute).load!
    run_entrypoint(loaded[:entrypoint], page, env)
  end

  Endpoint.new(
    server: build_server(entrypoint),
    path: path
  )
end

#build_endpoint(path: nil) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/ruflet/rails/protocol/runner.rb', line 11

def build_endpoint(path: nil)
  raise ArgumentError, "Ruflet::Rails::Protocol endpoint requires a block" unless @entrypoint.respond_to?(:call)

  Endpoint.new(server: build_server(@entrypoint), path: path)
end