Class: Larva::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/larva/processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Processor

Returns a new instance of Processor.



8
9
10
11
12
13
# File 'lib/larva/processor.rb', line 8

def initialize(message)
  @message = message
  @action = message[:action]
  @entity = message[:entity]
  @id = message[:id]
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



7
8
9
# File 'lib/larva/processor.rb', line 7

def action
  @action
end

#entityObject

Returns the value of attribute entity.



7
8
9
# File 'lib/larva/processor.rb', line 7

def entity
  @entity
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/larva/processor.rb', line 7

def id
  @id
end

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/larva/processor.rb', line 7

def message
  @message
end

Class Method Details

.process(message) ⇒ Object



3
4
5
# File 'lib/larva/processor.rb', line 3

def self.process(message)
  new(message).process_with_logging
end

Instance Method Details

#process_with_loggingObject



15
16
17
18
19
20
21
22
# File 'lib/larva/processor.rb', line 15

def process_with_logging
  Propono.config.logger.info "Processing message: #{message}"
  if self.process
    Propono.config.logger.info "Message Processed: #{message}"
  else
    Propono.config.logger.info "Unrecognized event type, entity: #{entity} action: #{action}."
  end
end