Class: Fosm::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/fosm/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fosm/configuration.rb', line 72

def initialize
  @base_controller          = "ApplicationController"
  @admin_authorize          = -> { true } # Override in initializer!
  @app_authorize            = ->(_level) { true } # Override in initializer!
  @current_user_method      = -> { defined?(current_user) ? current_user : nil }
  @admin_layout             = "fosm/application"
  @app_layout               = "application"
  @transition_log_strategy  = :sync
  @webhook_job_queue        = :default
  @transition_log_job_queue = :fosm_audit
  @webhooks_enabled         = true
  @data_retention_days      = Fosm::DATA_RETENTION_DEFAULT_DAYS
end

Instance Attribute Details

#admin_authorizeObject

A callable that authorizes access to the /fosm/admin area. Called via instance_exec in the controller before_action. Example: -> { redirect_to root_path unless current_user&.superadmin? }



14
15
16
# File 'lib/fosm/configuration.rb', line 14

def admin_authorize
  @admin_authorize
end

#admin_layoutObject

Layout used for the admin section



26
27
28
# File 'lib/fosm/configuration.rb', line 26

def admin_layout
  @admin_layout
end

#app_authorizeObject

A callable that authorizes access to individual FOSM apps. Receives the access_level declared in the app definition. Example: ->(level) { authenticate_user! }



19
20
21
# File 'lib/fosm/configuration.rb', line 19

def app_authorize
  @app_authorize
end

#app_layoutObject

Default layout used for generated FOSM app views



29
30
31
# File 'lib/fosm/configuration.rb', line 29

def app_layout
  @app_layout
end

#base_controllerObject

The base controller class the engine’s controllers will inherit from. Set this to match your app’s ApplicationController.



9
10
11
# File 'lib/fosm/configuration.rb', line 9

def base_controller
  @base_controller
end

#current_user_methodObject

A callable that returns the current user from the controller context. Used for transition log actor tracking.



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

def current_user_method
  @current_user_method
end

#data_retention_daysObject

Data retention policy in days. Records in an archival terminal state (state name contains “archiv”) with an ‘archived_at` timestamp older than this many days are eligible for purge from the Data Archival admin.

Gem default: Fosm::DATA_RETENTION_DEFAULT_DAYS (3650 = 10 years). Override per-project in config/initializers/fosm.rb:

config.data_retention_days = 2555  # 7 years


70
71
72
# File 'lib/fosm/configuration.rb', line 70

def data_retention_days
  @data_retention_days
end

#transition_log_job_queueObject

Queue name for Fosm::TransitionLogJob (used when transition_log_strategy = :async).

Example:

config.transition_log_job_queue = :low


53
54
55
# File 'lib/fosm/configuration.rb', line 53

def transition_log_job_queue
  @transition_log_job_queue
end

#transition_log_strategyObject

Strategy for writing transition logs.

:sync — INSERT inside the fire! transaction (strictest consistency, default) :async — SolidQueue/ActiveJob after commit (non-blocking, recommended for production) :buffered — Bulk INSERT via periodic thread flush (highest throughput, opt-in)

Example:

config.transition_log_strategy = :async


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

def transition_log_strategy
  @transition_log_strategy
end

#webhook_job_queueObject

Queue name for Fosm::WebhookDeliveryJob. Webhook delivery is fire-and-forget; route it to a low-priority queue to avoid competing with user-facing jobs on the default queue.

Example:

config.webhook_job_queue = :low


47
48
49
# File 'lib/fosm/configuration.rb', line 47

def webhook_job_queue
  @webhook_job_queue
end

#webhooks_enabledObject

When false, skip enqueuing WebhookDeliveryJob after every transition. Set to false if your app has no webhook subscriptions to eliminate unnecessary queue writes (reduces SQLite write pressure).

Example:

config.webhooks_enabled = false


61
62
63
# File 'lib/fosm/configuration.rb', line 61

def webhooks_enabled
  @webhooks_enabled
end