Class: Woods::Notion::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/notion/mapper.rb

Overview

Dispatcher for Notion mappers. Returns the appropriate mapper for a unit type.

Examples:

mapper = Mapper.for("model")
properties = mapper.map(unit_data)

Constant Summary collapse

REGISTRY =
{
  'model' => Mappers::ModelMapper,
  'column' => Mappers::ColumnMapper,
  'migration' => Mappers::MigrationMapper
}.freeze

Class Method Summary collapse

Class Method Details

.for(type) ⇒ Object?

Get a mapper instance for a unit type.

Parameters:

  • type (String)

    Unit type name (e.g. “model”, “column”, “migration”)

Returns:

  • (Object, nil)

    Mapper instance or nil if type is not supported



27
28
29
30
# File 'lib/woods/notion/mapper.rb', line 27

def self.for(type)
  klass = REGISTRY[type]
  klass&.new
end

.supported_typesArray<String>

List all supported unit types.

Returns:

  • (Array<String>)


35
36
37
# File 'lib/woods/notion/mapper.rb', line 35

def self.supported_types
  REGISTRY.keys
end