Class: Suma::SchemaCategory
- Inherits:
-
Object
- Object
- Suma::SchemaCategory
- Defined in:
- lib/suma/schema_category.rb
Overview
Value object mapping an ExpressSchema::Type to its register/export category.
Single source of truth for category identity across the codebase: directory layout (SchemaExporter), display prefix (SchemaNaming), and register.yaml sections (RegisterManifestGenerator) all derive from this.
Each category carries: id (slug used in register.yaml section id and
export subdirectory), label (human-readable section heading),
prefix (prefix used when forming display names, e.g. "Resource: ..."),
types (Array of ExpressSchema::Type symbols that belong to it),
and directory (subdirectory name; "." for the root output path).
Constant Summary collapse
- RESOURCES =
new( id: "resources", label: "Resources", prefix: "Resource", types: [ExpressSchema::Type::RESOURCE].freeze, directory: "resources", )
- MODULES =
new( id: "modules", label: "Application Modules", prefix: "Module", types: [ExpressSchema::Type::MODULE_ARM, ExpressSchema::Type::MODULE_MIM].freeze, directory: "modules", )
- BUSINESS_OBJECT_MODELS =
new( id: "business_object_models", label: "Business Object Models", prefix: "Business Object Model", types: [ExpressSchema::Type::BUSINESS_OBJECT_MODEL].freeze, directory: "business_object_models", )
- CORE_MODEL =
new( id: "core_model", label: "Core Model", prefix: "Core Model", types: [ExpressSchema::Type::CORE_MODEL].freeze, directory: "core_model", )
- OTHER =
new( id: "other", label: "Other Schemas", prefix: "Schema", types: [ExpressSchema::Type::STANDALONE].freeze, directory: ".", )
- ALL =
[ RESOURCES, MODULES, BUSINESS_OBJECT_MODELS, CORE_MODEL, OTHER, ].freeze
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, label:, prefix:, types:, directory:) ⇒ SchemaCategory
constructor
A new instance of SchemaCategory.
- #member?(type) ⇒ Boolean
Constructor Details
#initialize(id:, label:, prefix:, types:, directory:) ⇒ SchemaCategory
Returns a new instance of SchemaCategory.
18 19 20 21 22 23 24 |
# File 'lib/suma/schema_category.rb', line 18 def initialize(id:, label:, prefix:, types:, directory:) @id = id @label = label @prefix = prefix @types = types @directory = directory end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
16 17 18 |
# File 'lib/suma/schema_category.rb', line 16 def directory @directory end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/suma/schema_category.rb', line 16 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
16 17 18 |
# File 'lib/suma/schema_category.rb', line 16 def label @label end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
16 17 18 |
# File 'lib/suma/schema_category.rb', line 16 def prefix @prefix end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
16 17 18 |
# File 'lib/suma/schema_category.rb', line 16 def types @types end |
Class Method Details
.for_schema(id:, path:) ⇒ Object
78 79 80 81 |
# File 'lib/suma/schema_category.rb', line 78 def self.for_schema(id:, path:) type = ExpressSchema::Type.classify(id: id, path: path) for_type(type) end |
Instance Method Details
#member?(type) ⇒ Boolean
26 27 28 |
# File 'lib/suma/schema_category.rb', line 26 def member?(type) types.include?(type) end |