module

Prostore::Schema::NameConversion

Translate a Crystal enum member's source-level name to the wire form selected by the field's naming: option (ADR-0017). Pure function; the macro calls this once per member when synthesising the schema record so the result is cached for the lifetime of the process.

The conversions are deliberately conservative:

  • :as_declared — no change (current 0.3.x behaviour).
  • :snake_case — BounceHard → bounce_hard. Mirrors the regex pair Crystal's String#underscore uses (and the FK ref-table derivation already in macros.cr).
  • :lower_case — BounceHard → bouncehard. For codebases that just downcase without word separation.
  • :kebab_case — BounceHard → bounce-hard. Same separation rule as snake_case but with hyphens.

Instance methods

apply(name : String, algorithm : Symbol) : String
Source