Class: DataMaps::Dsl::Mapping::ConditionsDsl

Inherits:
Struct
  • Object
show all
Includes:
Concerns::Configurable
Defined in:
lib/data_maps/dsl/mapping/conditions_dsl.rb

Overview

Structure to describe a field mapping

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Configurable

#configure

Constructor Details

#initializeConditionsDsl

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

#thensObject

Returns the value of attribute thens

Returns:

  • (Object)

    the current value of thens



5
6
7
# File 'lib/data_maps/dsl/mapping/conditions_dsl.rb', line 5

def thens
  @thens
end

#whensObject

Returns the value of attribute whens

Returns:

  • (Object)

    the current value of 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_hObject

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