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.
14
15
16
17
18
|
# File 'lib/lutaml/model/transform.rb', line 14
def initialize(context, register = nil)
@context = context
@attributes = context.attributes
@register = register || Lutaml::Model::Config.default_register
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
12
13
14
|
# File 'lib/lutaml/model/transform.rb', line 12
def attributes
@attributes
end
|
#context ⇒ Object
Returns the value of attribute context.
12
13
14
|
# File 'lib/lutaml/model/transform.rb', line 12
def context
@context
end
|
#register ⇒ Object
Returns the value of attribute register.
12
13
14
|
# File 'lib/lutaml/model/transform.rb', line 12
def register
@register
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, options[:register]).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.register).model_to_data(model, format, options)
end
|
Instance Method Details
#data_to_model(data, options = {}) ⇒ Object
24
25
26
|
# File 'lib/lutaml/model/transform.rb', line 24
def data_to_model(data, options = {})
raise NotImplementedError, "#{self.class.name} must implement `data_to_model`."
end
|
#model_class ⇒ Object
20
21
22
|
# File 'lib/lutaml/model/transform.rb', line 20
def model_class
@context.model
end
|
#model_to_data(model, options = {}) ⇒ Object
28
29
30
|
# File 'lib/lutaml/model/transform.rb', line 28
def model_to_data(model, options = {})
raise NotImplementedError, "#{self.class.name} must implement `model_to_data`."
end
|