Exception: Funes::InvalidMaterializationState
- Inherits:
-
StandardError
- Object
- StandardError
- Funes::InvalidMaterializationState
- Defined in:
- lib/funes/invalid_materialization_state.rb
Overview
Raised when a projection configured with ‘persist_materialization_model_with` produces an invalid materialization state.
When a projection declares a custom persistence method via ‘persist_materialization_model_with`, Funes still validates the materialization (via `state.valid?`) before delegating the write. If validation fails, this exception is raised and the custom persist method is not invoked.
The failed materialization is exposed via ‘#record`, mirroring the ergonomics of `ActiveRecord::RecordInvalid` — but without coupling the custom-persist path to ActiveRecord. Like any unrescued exception, it propagates out of `materialize!` and rolls back any enclosing `ActiveRecord::Base.transaction`, which is the desired behaviour for transactional projections.
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(record) ⇒ InvalidMaterializationState
constructor
A new instance of InvalidMaterializationState.
Constructor Details
#initialize(record) ⇒ InvalidMaterializationState
Returns a new instance of InvalidMaterializationState.
26 27 28 29 |
# File 'lib/funes/invalid_materialization_state.rb', line 26 def initialize(record) @record = record super("Invalid materialization state: #{record.errors..to_sentence}") end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
24 25 26 |
# File 'lib/funes/invalid_materialization_state.rb', line 24 def record @record end |