Class: DataMaps::Dsl::Mapping::FieldMappingDsl
- Inherits:
-
Struct
- Object
- Struct
- DataMaps::Dsl::Mapping::FieldMappingDsl
- Includes:
- Concerns::Configurable
- Defined in:
- lib/data_maps/dsl/mapping/field_dsl.rb
Overview
Structure to describe a field mapping
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#converter ⇒ Object
Returns the value of attribute converter.
-
#from ⇒ Object
Returns the value of attribute from.
Instance Method Summary collapse
- #condition(&block) ⇒ Object
- #convert(converter, options = nil) ⇒ Object
-
#initialize(options = {}) ⇒ FieldMappingDsl
constructor
A new instance of FieldMappingDsl.
-
#to_h ⇒ Object
Serialize DSL to an Hash.
Methods included from Concerns::Configurable
Constructor Details
#initialize(options = {}) ⇒ FieldMappingDsl
Returns a new instance of FieldMappingDsl.
8 9 10 11 12 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 8 def initialize( = {}) self.from = [:from] self.conditions = [] self.converter = [] end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions
5 6 7 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 5 def conditions @conditions end |
#converter ⇒ Object
Returns the value of attribute converter
5 6 7 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 5 def converter @converter end |
#from ⇒ Object
Returns the value of attribute from
5 6 7 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 5 def from @from end |
Instance Method Details
#condition(&block) ⇒ Object
14 15 16 17 18 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 14 def condition(&block) dsl = DataMaps::Dsl::Mapping::ConditionsDsl.new dsl.configure(&block) if block_given? self.conditions << dsl.to_h end |
#convert(converter, options = nil) ⇒ Object
20 21 22 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 20 def convert(converter, = nil) self.converter << { apply: converter, option: } end |
#to_h ⇒ Object
Serialize DSL to an Hash
25 26 27 28 29 |
# File 'lib/data_maps/dsl/mapping/field_dsl.rb', line 25 def to_h data = super data[:convert] = data.delete(:converter) data.stringify_keys end |