Class: SolidObjects::ComponentPathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_objects/component_path_resolver.rb,
sig/generated/lib/solid_objects/component_path_resolver.rbs

Instance Method Summary collapse

Instance Method Details

#call(view_context:) ⇒ String

RBS:

  • (view_context: untyped) -> String

Parameters:

  • view_context: (Object)

Returns:

  • (String)


6
7
8
9
10
11
12
13
# File 'lib/solid_objects/component_path_resolver.rb', line 6

def call(view_context:)
  unless mounted?
    raise UnsupportedComponentRendering,
      "reactive components require the SolidObjects::Engine to be mounted in the host routes"
  end

  SolidObjects::Engine.routes.url_helpers.components_path
end

#mounted?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/solid_objects/component_path_resolver.rb', line 18

def mounted?
  return false unless defined?(Rails) && Rails.application

  Rails.application.routes.routes.any? do |route|
    route.app.respond_to?(:app) &&
      route.app.app.equal?(SolidObjects::Engine)
  end
end