Module: Opencdd::MetaClass::MetaClasses
- Defined in:
- lib/opencdd/meta_class.rb
Constant Summary collapse
- CODE_PROPERTY_IDS =
{ "MDC_C002" => "MDC_P001_5", "MDC_C003" => "MDC_P001_6", "MDC_C005" => "MDC_P001_12", "MDC_C011" => "MDC_P001_13", "MDC_C009" => "MDC_P001_10", "MDC_C010" => "MDC_P001_11", "EXT_C001" => "EXT_P001", }.freeze
- TYPE_BY_META_CLASS =
{ "MDC_C002" => :class, "MDC_C003" => :property, "MDC_C005" => :value_list, "MDC_C011" => :relation, "MDC_C009" => :unit, "MDC_C010" => :value_term, "EXT_C001" => :view_control, }.freeze
Class Method Summary collapse
- .all ⇒ Object
- .code_property_id_for(irdi) ⇒ Object
- .codes ⇒ Object
- .common_property_ids ⇒ Object
-
.entity_class_for_type(type) ⇒ Object
Reverse of
meta_class_for_type: returns the Ruby entity class (Opencdd::Klass, Opencdd::Property, etc.) registered for a giventypeSymbol. - .for(irdi) ⇒ Object
- .meta_class_for_type(type) ⇒ Object
- .register(meta_class) ⇒ Object
- .reset! ⇒ Object
- .sheet_type_for(irdi) ⇒ Object
-
.sheet_type_for_type(type) ⇒ Object
Parcel sheet-type label ("CLASS", "PROPERTY", "ENUM", "TERMINOLOGY", "UoM", "RELATION", "VIEWCONTROL") for a given
typeSymbol. - .type_for(irdi) ⇒ Object
Class Method Details
.all ⇒ Object
114 115 116 117 |
# File 'lib/opencdd/meta_class.rb', line 114 def all ensure_loaded @registry.values end |
.code_property_id_for(irdi) ⇒ Object
134 135 136 |
# File 'lib/opencdd/meta_class.rb', line 134 def code_property_id_for(irdi) CODE_PROPERTY_IDS[irdi.to_s] end |
.codes ⇒ Object
119 120 121 122 |
# File 'lib/opencdd/meta_class.rb', line 119 def codes ensure_loaded @registry.keys end |
.common_property_ids ⇒ Object
98 99 100 |
# File 'lib/opencdd/meta_class.rb', line 98 def common_property_ids Opencdd::PropertyIds::REGISTRY.select { |_, e| e.applies_to == :all }.keys.freeze end |
.entity_class_for_type(type) ⇒ Object
Reverse of meta_class_for_type: returns the Ruby entity
class (Opencdd::Klass, Opencdd::Property, etc.) registered
for a given type Symbol. Single source of truth — used
by Database#add_workbook to dispatch entity construction
without maintaining its own type→class map.
143 144 145 146 147 148 |
# File 'lib/opencdd/meta_class.rb', line 143 def entity_class_for_type(type) code = (type) return nil unless code ensure_loaded @registry[code]&.entity_class end |
.for(irdi) ⇒ Object
109 110 111 112 |
# File 'lib/opencdd/meta_class.rb', line 109 def for(irdi) ensure_loaded @registry[irdi.to_s] end |
.meta_class_for_type(type) ⇒ Object
163 164 165 |
# File 'lib/opencdd/meta_class.rb', line 163 def (type) TYPE_BY_META_CLASS.key(type.to_sym) || TYPE_BY_META_CLASS.key(type.to_s.to_sym) end |
.register(meta_class) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/opencdd/meta_class.rb', line 101 def register() ensure_loaded existing = @registry[.irdi] merged = existing ? existing.merge() : @registry[.irdi] = merged merged end |
.reset! ⇒ Object
124 125 126 127 128 |
# File 'lib/opencdd/meta_class.rb', line 124 def reset! @registry = built_in_registry define_code_constants! self end |
.sheet_type_for(irdi) ⇒ Object
158 159 160 161 |
# File 'lib/opencdd/meta_class.rb', line 158 def sheet_type_for(irdi) ensure_loaded @registry[irdi.to_s]&.sheet_type end |
.sheet_type_for_type(type) ⇒ Object
Parcel sheet-type label ("CLASS", "PROPERTY", "ENUM",
"TERMINOLOGY", "UoM", "RELATION", "VIEWCONTROL") for a
given type Symbol. Used by Database#build_sheetmap_for
and Parcel::Writer instead of local lookup tables.
154 155 156 |
# File 'lib/opencdd/meta_class.rb', line 154 def sheet_type_for_type(type) MetaClass::PARCEL_SHEET_TYPES[type.to_sym] end |
.type_for(irdi) ⇒ Object
130 131 132 |
# File 'lib/opencdd/meta_class.rb', line 130 def type_for(irdi) TYPE_BY_META_CLASS[irdi.to_s] end |