Class: Clickwrap::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/clickwrap/engine.rb

Overview

The mountable engine: wires autoloading, migrations, locales, the ActiveRecord macro, the form-builder extension, the controller helpers, and boot-time policy loading into the host app.

Constant Summary collapse

LIB_ROOT =

Zeitwerk: the gem keeps its ActiveRecord models under lib/clickwrap/models (same layout as the moderate and chats gems) so the whole domain ships in lib/ and the engine's app/ tree only holds the web layer. For that to autoload correctly we manage the loader by hand:

- `push_dir(lib/clickwrap, namespace: Clickwrap)` makes
lib/clickwrap/models/... autoloadable *under the Clickwrap namespace*.
- `collapse(models)` + `collapse(models/concerns)` mean the files in
those folders define Clickwrap::Event / Clickwrap::HasClickwraps —
not Clickwrap::Models::Event.
- The SPINE files are required explicitly by lib/clickwrap.rb at boot,
so they must be *ignored* by the loader or Zeitwerk would complain
about double definitions.

File.expand_path("..", __dir__)
CLICKWRAP_LIB =
File.expand_path("clickwrap", LIB_ROOT)
ZEITWERK_IGNORED =
%w[
  version.rb
  errors.rb
  vocabulary.rb
  canonical_json.rb
  digest.rb
  identifier.rb
  ip_geolocation.rb
  ip_geolocation/location.rb
  ip_geolocation/resolver.rb
  ip_geolocation/null_resolver.rb
  ip_geolocation/static_resolver.rb
  ip_geolocation/trackdown_resolver.rb
  configuration.rb
  engine.rb
  macros.rb
  authority.rb
  registry.rb
  localized_text.rb
  document_definition.rb
  statement.rb
  request_evidence_policy.rb
  policy.rb
  retention_class.rb
  dsl/policy_builder.rb
  dsl/retention_builder.rb
  document_renderers/markdown.rb
  form_builder_extensions.rb
  view_helpers.rb
  controller_helpers.rb
  registration.rb
].freeze