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",
  "MDC_C0100" => "C0101",
  "MDC_C0101" => "MDC_P001_5",
  "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,
  "MDC_C0100" => :list_of_unit,
  "MDC_C0101" => :det_classification,
  "IECCDD_001" => :det_classification,
  "EXT_C001" => :view_control,
}.freeze

Class Method Summary collapse

Class Method Details

.allObject



119
120
121
122
# File 'lib/opencdd/meta_class.rb', line 119

def all
  ensure_loaded
  @registry.values
end

.code_property_id_for(irdi) ⇒ Object



139
140
141
# File 'lib/opencdd/meta_class.rb', line 139

def code_property_id_for(irdi)
  CODE_PROPERTY_IDS[irdi.to_s]
end

.codesObject



124
125
126
127
# File 'lib/opencdd/meta_class.rb', line 124

def codes
  ensure_loaded
  @registry.keys
end

.common_property_idsObject



103
104
105
# File 'lib/opencdd/meta_class.rb', line 103

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.



148
149
150
151
152
153
# File 'lib/opencdd/meta_class.rb', line 148

def entity_class_for_type(type)
  code = meta_class_for_type(type)
  return nil unless code
  ensure_loaded
  @registry[code]&.entity_class
end

.for(irdi) ⇒ Object



114
115
116
117
# File 'lib/opencdd/meta_class.rb', line 114

def for(irdi)
  ensure_loaded
  @registry[irdi.to_s]
end

.meta_class_for_type(type) ⇒ Object



168
169
170
# File 'lib/opencdd/meta_class.rb', line 168

def meta_class_for_type(type)
  TYPE_BY_META_CLASS.key(type.to_sym) || TYPE_BY_META_CLASS.key(type.to_s.to_sym)
end

.register(meta_class) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/opencdd/meta_class.rb', line 106

def register(meta_class)
  ensure_loaded
  existing = @registry[meta_class.irdi]
  merged = existing ? existing.merge(meta_class) : meta_class
  @registry[meta_class.irdi] = merged
  merged
end

.reset!Object



129
130
131
132
133
# File 'lib/opencdd/meta_class.rb', line 129

def reset!
  @registry = built_in_registry
  define_code_constants!
  self
end

.sheet_type_for(irdi) ⇒ Object



163
164
165
166
# File 'lib/opencdd/meta_class.rb', line 163

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.



159
160
161
# File 'lib/opencdd/meta_class.rb', line 159

def sheet_type_for_type(type)
  MetaClass::PARCEL_SHEET_TYPES[type.to_sym]
end

.type_for(irdi) ⇒ Object



135
136
137
# File 'lib/opencdd/meta_class.rb', line 135

def type_for(irdi)
  TYPE_BY_META_CLASS[irdi.to_s]
end