Class: Threatstack::Events::BaseEvent
- Inherits:
- 
      Object
      
        - Object
- Threatstack::Events::BaseEvent
 
- Defined in:
- lib/events/models/base_event.rb
Overview
Base event model containing the common attributes
Direct Known Subclasses
AttackEvent, DependencyEvent, EnvironmentEvent, InstrumentationEvent
Instance Attribute Summary collapse
- 
  
    
      #agent_type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute agent_type. 
- 
  
    
      #event_id  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute event_id. 
- 
  
    
      #event_type  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute event_type. 
- 
  
    
      #timestamp  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute timestamp. 
Instance Method Summary collapse
- 
  
    
      #initialize(args)  ⇒ BaseEvent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of BaseEvent. 
- #to_core_hash ⇒ Object
- #to_hash ⇒ Object
- #to_json_string ⇒ Object
Constructor Details
#initialize(args) ⇒ BaseEvent
Returns a new instance of BaseEvent.
| 21 22 23 24 25 26 | # File 'lib/events/models/base_event.rb', line 21 def initialize(args) @event_id = args[:event_id].nil? ? SecureRandom.uuid : args[:event_id] @timestamp = args[:timestamp].nil? ? Time.now.utc.strftime('%FT%T.%3NZ') : args[:timestamp] @event_type = args[:event_type] @agent_type = Threatstack::Constants::RUBY end | 
Instance Attribute Details
#agent_type ⇒ Object (readonly)
Returns the value of attribute agent_type.
| 15 16 17 | # File 'lib/events/models/base_event.rb', line 15 def agent_type @agent_type end | 
#event_id ⇒ Object
Returns the value of attribute event_id.
| 12 13 14 | # File 'lib/events/models/base_event.rb', line 12 def event_id @event_id end | 
#event_type ⇒ Object
Returns the value of attribute event_type.
| 13 14 15 | # File 'lib/events/models/base_event.rb', line 13 def event_type @event_type end | 
#timestamp ⇒ Object
Returns the value of attribute timestamp.
| 14 15 16 | # File 'lib/events/models/base_event.rb', line 14 def @timestamp end | 
Instance Method Details
#to_core_hash ⇒ Object
| 32 33 34 | # File 'lib/events/models/base_event.rb', line 32 def to_core_hash { :event_id => @event_id, :event_type => @event_type, :agent_type => @agent_type, :timestamp => @timestamp } end | 
#to_hash ⇒ Object
| 28 29 30 | # File 'lib/events/models/base_event.rb', line 28 def to_hash Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }] end | 
#to_json_string ⇒ Object
| 36 37 38 | # File 'lib/events/models/base_event.rb', line 36 def to_json_string to_hash.to_json end |