Class: Lutaml::Model::Transformer

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

Direct Known Subclasses

ExportTransformer, ImportTransformer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, attribute) ⇒ Transformer



12
13
14
15
# File 'lib/lutaml/model/services/transformer.rb', line 12

def initialize(rule, attribute)
  @rule = rule
  @attribute = attribute
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



10
11
12
# File 'lib/lutaml/model/services/transformer.rb', line 10

def attribute
  @attribute
end

#ruleObject (readonly)

Returns the value of attribute rule.



10
11
12
# File 'lib/lutaml/model/services/transformer.rb', line 10

def rule
  @rule
end

Class Method Details

.call(value, rule, attribute) ⇒ Object



5
6
7
# File 'lib/lutaml/model/services/transformer.rb', line 5

def call(value, rule, attribute)
  new(rule, attribute).call(value)
end

Instance Method Details

#call(value) ⇒ Object



17
18
19
20
21
# File 'lib/lutaml/model/services/transformer.rb', line 17

def call(value)
  transformation_methods.reduce(value) do |transformed_value, method|
    method.call(transformed_value)
  end
end