Class: TableSync::ConfigDecorator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
EventActions
Defined in:
lib/table_sync/config_decorator.rb

Overview

rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper

Instance Method Summary collapse

Methods included from EventActions

#destroy, #expected_update_result?, #prevent_incomplete_event!, #process_destroy, #process_upsert, #update, #with_wrapping

Constructor Details

#initialize(config, handler) ⇒ ConfigDecorator

Returns a new instance of ConfigDecorator.



11
12
13
14
# File 'lib/table_sync/config_decorator.rb', line 11

def initialize(config, handler)
  @config = config
  @handler = handler
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/table_sync/config_decorator.rb', line 16

def method_missing(name, *args)
  value = @config.send(name)

  if value.is_a?(Proc)
    value.call(
      event: @handler.event,
      model: @handler.model,
      version: @handler.version,
      project_id: @handler.project_id,
      data: @handler.data,
      current_row: args.first,
    )
  else
    value
  end
end

Instance Method Details

#allow_event?(event) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/table_sync/config_decorator.rb', line 33

def allow_event?(event)
  @config.allow_event?(event)
end