Class: Woods::Notion::Mappers::ColumnMapper
- Inherits:
-
Object
- Object
- Woods::Notion::Mappers::ColumnMapper
- Includes:
- Shared
- Defined in:
- lib/woods/notion/mappers/column_mapper.rb
Overview
Maps individual column metadata to Notion page properties for the Columns database.
Each column from a model’s metadata becomes a separate Notion page, optionally linked to its parent Data Models page via a relation property.
Constant Summary
Constants included from Shared
Instance Method Summary collapse
-
#map(column, model_identifier: nil, validations: [], parent_page_id: nil) ⇒ Hash
Map a single column to Notion Columns page properties.
Methods included from Shared
Instance Method Details
#map(column, model_identifier: nil, validations: [], parent_page_id: nil) ⇒ Hash
Map a single column to Notion Columns page properties.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/woods/notion/mappers/column_mapper.rb', line 27 def map(column, model_identifier: nil, validations: [], parent_page_id: nil) # rubocop:disable Lint/UnusedMethodArgument properties = { 'Column Name' => { title: [{ text: { content: column['name'] } }] }, 'Data Type' => { select: { name: column['type'] } }, 'Nullable' => { checkbox: column['null'] == true }, 'Default Value' => rich_text_property(column['default'].to_s), 'Validation Rules' => rich_text_property(format_validation_rules(column['name'], validations)) } properties['Table'] = { relation: [{ id: parent_page_id }] } if parent_page_id properties end |