Class: StandardLedger::Projector::TriggerDsl
- Inherits:
-
Object
- Object
- StandardLedger::Projector::TriggerDsl
- Defined in:
- lib/standard_ledger/projector.rb
Overview
Internal collector for the ‘:trigger`-mode block-DSL form. Captures the `rebuild_sql “…”` clause’s SQL string. The trigger itself is owned by the host (created in a Rails migration); the gem only records this rebuild SQL so ‘StandardLedger.rebuild!` can recompute the projection from the log when invoked. Like `:sql` mode, the SQL must be expressible as a single statement with `:target_id` bound from each target’s id at rebuild time.
Instance Attribute Summary collapse
-
#rebuild_sql_text ⇒ Object
readonly
Returns the value of attribute rebuild_sql_text.
Instance Method Summary collapse
Instance Attribute Details
#rebuild_sql_text ⇒ Object (readonly)
Returns the value of attribute rebuild_sql_text.
512 513 514 |
# File 'lib/standard_ledger/projector.rb', line 512 def rebuild_sql_text @rebuild_sql_text end |
Instance Method Details
#rebuild_sql(sql) ⇒ Object
514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/standard_ledger/projector.rb', line 514 def rebuild_sql(sql) unless sql.is_a?(String) raise ArgumentError, "rebuild_sql requires a SQL string; got #{sql.class}" end unless @rebuild_sql_text.nil? raise ArgumentError, "rebuild_sql called more than once in the same projects_onto block; " \ ":trigger mode supports exactly one rebuild_sql clause per projection" end @rebuild_sql_text = sql end |