Class: DataMaps::Dsl::Mapping::ConditionsDsl
- Inherits:
-
Struct
- Object
- Struct
- DataMaps::Dsl::Mapping::ConditionsDsl
- Includes:
- Concerns::Configurable
- Defined in:
- lib/data_maps/dsl/mapping/conditions_dsl.rb
Overview
Structure to describe a field mapping
Instance Attribute Summary collapse
-
#thens ⇒ Object
Returns the value of attribute thens.
-
#whens ⇒ Object
Returns the value of attribute whens.
Instance Method Summary collapse
-
#initialize ⇒ ConditionsDsl
constructor
A new instance of ConditionsDsl.
- #then(action, option) ⇒ Object (also: #so)
-
#to_h ⇒ Object
Serialize DSL to an Hash.
- #when(condition, option) ⇒ Object (also: #is)
Methods included from Concerns::Configurable
Constructor Details
#initialize ⇒ ConditionsDsl
Returns a new instance of ConditionsDsl.
8 9 10 11 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 8 def initialize self.whens = {} self.thens = {} end |
Instance Attribute Details
#thens ⇒ Object
Returns the value of attribute thens
5 6 7 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 5 def thens @thens end |
#whens ⇒ Object
Returns the value of attribute whens
5 6 7 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 5 def whens @whens end |
Instance Method Details
#then(action, option) ⇒ Object Also known as: so
18 19 20 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 18 def then(action, option) self.thens[action] = option end |
#to_h ⇒ Object
Serialize DSL to an Hash
24 25 26 27 28 29 30 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 24 def to_h data = { when: whens, then: thens } data.stringify_keys end |
#when(condition, option) ⇒ Object Also known as: is
13 14 15 |
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 13 def when(condition, option) self.whens[condition] = option end |