Class: DeltaCore::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/delta_core/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
# File 'lib/delta_core/configuration.rb', line 7

def initialize
  @snapshot_column = nil
  @mappings        = []
end

Instance Attribute Details

#mappings ⇒ Object (readonly)

Returns the value of attribute mappings.



5
6
7
# File 'lib/delta_core/configuration.rb', line 5

def mappings
  @mappings
end

Instance Method Details

#map(name, key:, strategy:, fields: [], relations: {}) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
# File 'lib/delta_core/configuration.rb', line 20

def map(name, key:, strategy:, fields: [], relations: {})
  sym = name.to_sym
  raise ArgumentError, "Duplicate mapping: #{sym}" if mapping_names.include?(sym)

  mapping = Mapping.new(sym, key: key, fields: fields, strategy: strategy, relations: relations)
  @mappings << mapping
  mapping
end

#snapshot_column(column_name = nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/delta_core/configuration.rb', line 12

def snapshot_column(column_name = nil)
  if column_name
    @snapshot_column = column_name.to_sym
  else
    @snapshot_column
  end
end