Class: Lutaml::Qea::Factory::BaseTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/qea/factory/base_transformer.rb

Overview

Abstract base class for all EA to UML transformers Implements the Strategy pattern for model transformation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ BaseTransformer

Initialize transformer with database reference

Parameters:



13
14
15
# File 'lib/lutaml/qea/factory/base_transformer.rb', line 13

def initialize(database)
  @database = database
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



9
10
11
# File 'lib/lutaml/qea/factory/base_transformer.rb', line 9

def database
  @database
end

Instance Method Details

#transform(ea_model) ⇒ Object

Transform a single EA model to UML model

Parameters:

  • ea_model (BaseModel)

    EA model instance

Returns:

  • (Object)

    UML model instance

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



21
22
23
24
# File 'lib/lutaml/qea/factory/base_transformer.rb', line 21

def transform(ea_model)
  raise NotImplementedError,
        "#{self.class} must implement #transform"
end

#transform_collection(collection) ⇒ Array<Object>

Transform a collection of EA models to UML models

Parameters:

  • collection (Array<BaseModel>)

    Collection of EA models

Returns:

  • (Array<Object>)

    Collection of UML models



29
30
31
32
33
# File 'lib/lutaml/qea/factory/base_transformer.rb', line 29

def transform_collection(collection)
  return [] if collection.nil? || collection.empty?

  collection.filter_map { |item| transform(item) }
end