Class: Lutaml::Model::Transform
- Inherits:
-
Object
- Object
- Lutaml::Model::Transform
show all
- Defined in:
- lib/lutaml/model/transform.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(context, register = nil) ⇒ Transform
Returns a new instance of Transform.
17
18
19
20
21
|
# File 'lib/lutaml/model/transform.rb', line 17
def initialize(context, register = nil)
@context = context
@lutaml_register = register || Lutaml::Model::Config.default_register
@attributes = context.attributes(lutaml_register)
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
15
16
17
|
# File 'lib/lutaml/model/transform.rb', line 15
def attributes
@attributes
end
|
#context ⇒ Object
Returns the value of attribute context.
15
16
17
|
# File 'lib/lutaml/model/transform.rb', line 15
def context
@context
end
|
#lutaml_register ⇒ Object
Returns the value of attribute lutaml_register.
15
16
17
|
# File 'lib/lutaml/model/transform.rb', line 15
def lutaml_register
@lutaml_register
end
|
Class Method Details
.data_to_model(context, data, format, options = {}) ⇒ Object
6
7
8
|
# File 'lib/lutaml/model/transform.rb', line 6
def self.data_to_model(context, data, format, options = {})
new(context, options[:register]).data_to_model(data, format, options)
end
|
.model_to_data(context, model, format, options = {}) ⇒ Object
10
11
12
13
|
# File 'lib/lutaml/model/transform.rb', line 10
def self.model_to_data(context, model, format, options = {})
register = model.lutaml_register if model.respond_to?(:lutaml_register)
new(context, register).model_to_data(model, format, options)
end
|
Instance Method Details
#data_to_model(data, options = {}) ⇒ Object
27
28
29
30
|
# File 'lib/lutaml/model/transform.rb', line 27
def data_to_model(data, options = {})
raise NotImplementedError,
"#{self.class.name} must implement `data_to_model`."
end
|
#model_class ⇒ Object
23
24
25
|
# File 'lib/lutaml/model/transform.rb', line 23
def model_class
@context.model
end
|
#model_to_data(model, options = {}) ⇒ Object
32
33
34
35
|
# File 'lib/lutaml/model/transform.rb', line 32
def model_to_data(model, options = {})
raise NotImplementedError,
"#{self.class.name} must implement `model_to_data`."
end
|