Class: Dionysus::Consumer::Persistor

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/consumer/persistor.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, topic) ⇒ Persistor

Returns a new instance of Persistor.



7
8
9
10
# File 'lib/dionysus/consumer/persistor.rb', line 7

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

Instance Method Details

#persist(dionysus_event, batch_number) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dionysus/consumer/persistor.rb', line 12

def persist(dionysus_event, batch_number)
  if dionysus_event.generic_event?
    if dionysus_event.created? && topic.options[:import] == true
      persist_via_dionysus_create(dionysus_event, batch_number)
    elsif dionysus_event.destroyed? && topic.options[:import] == true
      persist_via_dionysus_destroy(dionysus_event, batch_number)
    else
      persist_standard_event(dionysus_event, batch_number)
    end
  else
    log_unknown_event_type(dionysus_event)
  end
end