Module: Ruact

Defined in:
lib/ruact.rb,
lib/ruact/query.rb,
lib/ruact/doctor.rb,
lib/ruact/errors.rb,
lib/ruact/flight.rb,
lib/ruact/server.rb,
lib/ruact/railtie.rb,
lib/ruact/routing.rb,
lib/ruact/version.rb,
lib/ruact/controller.rb,
lib/ruact/view_helper.rb,
lib/ruact/serializable.rb,
lib/ruact/configuration.rb,
lib/ruact/server_action.rb,
lib/ruact/flight/request.rb,
lib/ruact/html_converter.rb,
lib/ruact/render_context.rb,
lib/ruact/client_manifest.rb,
lib/ruact/flight/renderer.rb,
lib/ruact/render_pipeline.rb,
lib/ruact/erb_preprocessor.rb,
lib/ruact/server_functions.rb,
lib/ruact/flight/serializer.rb,
lib/ruact/flight/row_emitter.rb,
lib/ruact/flight/react_element.rb,
lib/ruact/erb_preprocessor_hook.rb,
lib/ruact/server_functions/codegen.rb,
lib/ruact/server_functions/registry.rb,
lib/ruact/server_functions/snapshot.rb,
lib/ruact/server_functions/codegen_v2.rb,
lib/ruact/server_functions/name_bridge.rb,
lib/ruact/server_functions/route_source.rb,
lib/ruact/server_functions/error_payload.rb,
lib/ruact/server_functions/query_context.rb,
lib/ruact/server_functions/query_dispatch.rb,
lib/ruact/server_functions/registry_entry.rb,
lib/ruact/server_functions/error_rendering.rb,
lib/ruact/server_functions/snapshot_writer.rb,
lib/ruact/server_functions/error_suggestion.rb,
lib/ruact/server_functions/backtrace_cleaner.rb,
lib/ruact/server_functions/bucket_two_payload.rb,
lib/ruact/server_functions/standalone_context.rb,
lib/generators/ruact/install/install_generator.rb,
lib/ruact/server_functions/endpoint_controller.rb,
lib/ruact/server_functions/standalone_dispatcher.rb

Defined Under Namespace

Modules: Controller, ErbPreprocessorHook, Flight, Generators, Routing, Serializable, Server, ServerAction, ServerFunctions, ViewHelper Classes: ActionError, ClientManifest, Configuration, ConfigurationError, CurrentUserNotConfiguredError, Doctor, ErbPreprocessor, Error, HtmlConverter, HtmlConverterError, ManifestError, PreprocessorError, Query, Railtie, RenderContext, RenderPipeline, SerializationError, UploadTooLargeError

Constant Summary collapse

VERSION =
"0.0.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.manifestObject

Returns the value of attribute manifest.



23
24
25
# File 'lib/ruact.rb', line 23

def manifest
  @manifest
end

.streaming_modeObject

Returns the value of attribute streaming_mode.



23
24
25
# File 'lib/ruact.rb', line 23

def streaming_mode
  @streaming_mode
end

Class Method Details

.action_registryRuact::ServerFunctions::Registry

Registry of ‘ruact_action` declarations. Populated by Story 8.1’s controller macro; consumed by Ruact::ServerFunctions::Snapshot when writing the Rails↔Vite bridge JSON.

Returns:



30
31
32
# File 'lib/ruact.rb', line 30

def action_registry
  @action_registry ||= ServerFunctions::Registry.new
end

.configRuact::Configuration

Returns the singleton configuration instance, frozen on first access so that mutation outside ‘Ruact.configure` always raises (Story 7.3). First-access publication counts as the boot configuration, so a later `Ruact.configure` call after default reads triggers the AC3 warning (otherwise the warning would be silently bypassed in apps that never call `Ruact.configure` at boot but reconfigure later).

Returns:



98
99
100
101
102
103
104
# File 'lib/ruact.rb', line 98

def config
  return @config if defined?(@config) && @config

  @config = Configuration.new.__send__(:seal!)
  @configured_at_least_once = true
  @config
end

.configure {|mutable| ... } ⇒ Object

Yields a mutable Configuration draft for block-style setup. The draft is frozen and atomically swapped into ‘Ruact.config` when the block returns. Mutating `Ruact.config` outside this block raises `Ruact::ConfigurationError` (Story 7.3).

When called a second time after boot, this method emits a ‘[ruact]` warning advising that runtime re-configuration is unusual.

Examples:

Ruact.configure do |config|
  config.strict_serialization = true
end

Yield Parameters:

  • mutable (Ruact::Configuration)

    draft cloned from the current configuration (or built from defaults on first call)



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ruact.rb', line 77

def configure
  draft = if defined?(@config) && @config
            Configuration.new(template: @config)
          else
            Configuration.new
          end

  yield draft

  warn_if_re_configuration!
  @config = draft.__send__(:seal!)
end

.gem_pathString

Story 8.4 — Absolute path to the gem’s ‘lib/` root. Used by Ruact::ServerFunctions::BacktraceCleaner to classify backtrace frames as APP or GEM. Memoised at first call so the per-frame `start_with?` check stays constant-time. Anchors on this file’s directory: ‘lib/ruact.rb` resolves to `lib/` after `expand_path(“..”, __dir__)`.

Returns:

  • (String)

    absolute path to the gem’s ‘lib/` directory



50
51
52
# File 'lib/ruact.rb', line 50

def gem_path
  @gem_path ||= File.expand_path("..", __dir__)
end

.query_registryRuact::ServerFunctions::Registry

Registry of ‘ruact_query` declarations. Populated by Story 9.1’s controller macro; consumed by Ruact::ServerFunctions::Snapshot when writing the Rails↔Vite bridge JSON.

Returns:



39
40
41
# File 'lib/ruact.rb', line 39

def query_registry
  @query_registry ||= ServerFunctions::Registry.new
end

.vite_plugin_pathString

Returns the absolute path to the Vite plugin bundled inside this gem. Use this in vite.config.js: import ruact from ‘<%= Ruact.vite_plugin_path %>’ Re-run ‘rails generate ruact:install` after gem upgrades to refresh the path.

Returns:

  • (String)

    absolute path to vendor/javascript/vite-plugin-ruact/index.js



59
60
61
# File 'lib/ruact.rb', line 59

def vite_plugin_path
  File.expand_path("../vendor/javascript/vite-plugin-ruact/index.js", __dir__)
end