Class: Charrington::TransformPostgres
- Inherits:
 - 
      Object
      
        
- Object
 - Charrington::TransformPostgres
 
 
- Includes:
 - Service
 
- Defined in:
 - lib/logstash/outputs/charrington/transform_postgres.rb
 
Overview
Inserts and modifies a Postgres database
Constant Summary collapse
- Error =
 Class.new(StandardError)
- EventNil =
 Class.new(Error)
- TableNameNil =
 Class.new(Error)
- ColumnBlacklist =
 Class.new(Error)
- KEY_FILTER_BLACKLIST =
 %w[host path jwt sequence].freeze
- KEY_RAISE_BLACKLIST =
 %w[id inserted_at].freeze
Instance Attribute Summary collapse
- 
  
    
      #event  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute event.
 - 
  
    
      #top_level_keys  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute top_level_keys.
 
Instance Method Summary collapse
- #call ⇒ Object
 - 
  
    
      #initialize(event)  ⇒ TransformPostgres 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of TransformPostgres.
 
Methods included from Service
Constructor Details
#initialize(event) ⇒ TransformPostgres
Returns a new instance of TransformPostgres.
      20 21 22 23 24 25 26 27  | 
    
      # File 'lib/logstash/outputs/charrington/transform_postgres.rb', line 20 def initialize(event) raise EventNil, 'Event is nil' if event.nil? event = event.to_hash @event = drop_keys(event) @top_level_keys = @event.keys check_blacklist end  | 
  
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
      9 10 11  | 
    
      # File 'lib/logstash/outputs/charrington/transform_postgres.rb', line 9 def event @event end  | 
  
#top_level_keys ⇒ Object (readonly)
Returns the value of attribute top_level_keys.
      10 11 12  | 
    
      # File 'lib/logstash/outputs/charrington/transform_postgres.rb', line 10 def top_level_keys @top_level_keys end  | 
  
Instance Method Details
#call ⇒ Object
      29 30 31 32 33 34  | 
    
      # File 'lib/logstash/outputs/charrington/transform_postgres.rb', line 29 def call flattened = flatten_hash(event) top_level_keys.each { |k| event.delete(k) } flattened.each_pair { |key, val| event[key] = val } event end  |