Class: StandardLedger::Projector::SqlDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_ledger/projector.rb

Overview

Internal collector for the ‘:sql`-mode block-DSL form. Captures the `recompute “…”` clause’s SQL string. Unlike ‘HandlerDsl` there are no per-kind handlers — the recompute SQL is the entire contract: it must be expressible as a single statement with `:target_id` bound from the entry’s foreign key, and it serves both the after-create path and ‘StandardLedger.rebuild!`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recompute_sqlObject (readonly)

Returns the value of attribute recompute_sql.



489
490
491
# File 'lib/standard_ledger/projector.rb', line 489

def recompute_sql
  @recompute_sql
end

Instance Method Details

#recompute(sql) ⇒ Object



491
492
493
494
495
496
497
498
499
500
501
# File 'lib/standard_ledger/projector.rb', line 491

def recompute(sql)
  unless sql.is_a?(String)
    raise ArgumentError, "recompute requires a SQL string; got #{sql.class}"
  end
  unless @recompute_sql.nil?
    raise ArgumentError,
          "recompute called more than once in the same projects_onto block; " \
          ":sql mode supports exactly one recompute clause per projection"
  end
  @recompute_sql = sql
end