Class: InlineForms::SchemaIntentRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- InlineForms::SchemaIntentRecord
- Defined in:
- app/models/inline_forms/schema_intent_record.rb
Overview
A persisted schema intent: one proposed "add attribute X of form-element Y to model Z at this position" row inside a SchemaBatch. This is the AR counterpart of the InlineForms::SchemaIntent value object (which stays a plain object in inline_forms); #to_schema_intent bridges the two.
Rows are editable only while their batch is a draft. migration_version
is the one exception: the pipeline backfills it after apply.
Constant Summary collapse
- BACKFILL_COLUMNS =
Pipeline backfill columns, writable after the batch froze.
%w[migration_version updated_at].freeze
Instance Method Summary collapse
-
#as_export ⇒ Object
Canonical export shape; also the digest input (see BatchExport), so key order is fixed and values are normalized strings/nil.
- #header? ⇒ Boolean
- #to_schema_intent ⇒ Object
Instance Method Details
#as_export ⇒ Object
Canonical export shape; also the digest input (see BatchExport), so key order is fixed and values are normalized strings/nil.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/models/inline_forms/schema_intent_record.rb', line 47 def as_export { "model_name" => target_model, "attribute" => attr_name, "form_element" => form_element, "after" => after_attr.presence, "before" => before_attr.presence, "label" => label.presence, "locale" => locale.presence } end |
#header? ⇒ Boolean
43 |
# File 'app/models/inline_forms/schema_intent_record.rb', line 43 def header? = form_element == "header" |
#to_schema_intent ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/models/inline_forms/schema_intent_record.rb', line 33 def to_schema_intent InlineForms::SchemaIntent.new( model_name: target_model, attribute: attr_name, form_element: form_element, after: after_attr.presence, before: before_attr.presence ) end |