Class: Lutaml::Model::Transform

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/transform.rb

Direct Known Subclasses

KeyValueTransform, XmlTransform

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Transform

Returns a new instance of Transform.



14
15
16
17
# File 'lib/lutaml/model/transform.rb', line 14

def initialize(context)
  @context = context
  @attributes = context.attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



12
13
14
# File 'lib/lutaml/model/transform.rb', line 12

def attributes
  @attributes
end

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/lutaml/model/transform.rb', line 12

def context
  @context
end

Class Method Details

.data_to_model(context, data, format, options = {}) ⇒ Object



4
5
6
# File 'lib/lutaml/model/transform.rb', line 4

def self.data_to_model(context, data, format, options = {})
  new(context).data_to_model(data, format, options)
end

.model_to_data(context, model, format, options = {}) ⇒ Object



8
9
10
# File 'lib/lutaml/model/transform.rb', line 8

def self.model_to_data(context, model, format, options = {})
  new(context).model_to_data(model, format, options)
end

Instance Method Details

#data_to_model(data, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/lutaml/model/transform.rb', line 23

def data_to_model(data, options = {})
  raise NotImplementedError, "#{self.class.name} must implement `data_to_model`."
end

#model_classObject



19
20
21
# File 'lib/lutaml/model/transform.rb', line 19

def model_class
  @context.model
end

#model_to_data(model, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/lutaml/model/transform.rb', line 27

def model_to_data(model, options = {})
  raise NotImplementedError, "#{self.class.name} must implement `model_to_data`."
end