Class: FFWD::Event

Inherits:
EventStruct show all
Defined in:
lib/ffwd/event.rb

Overview

A convenience class for each individual event.

Instance Attribute Summary

Attributes inherited from EventStruct

#description, #external_attr, #external_tags, #fixed_attr, #fixed_tags, #host, #key, #source, #state, #time, #ttl, #value

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.make(opts = {}) ⇒ Object



49
50
51
52
53
54
# File 'lib/ffwd/event.rb', line 49

def self.make opts = {}
  new(opts[:time], opts[:key], opts[:value], opts[:host], opts[:source],
      opts[:state], opts[:description], opts[:ttl],
      opts[:tags], opts[:fixed_tags],
      opts[:attributes], opts[:fixed_attr])
end

Instance Method Details

#attributesObject

maintained for backwards compatibility, but implementors are encouraged to use internal/external attributes directly.



58
59
60
# File 'lib/ffwd/event.rb', line 58

def attributes
  FFWD.merge_hashes fixed_attr, external_attr
end

#tagsObject



62
63
64
# File 'lib/ffwd/event.rb', line 62

def tags
  FFWD.merge_sets fixed_tags, external_tags
end

#to_hObject

Convert event to a sparse hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ffwd/event.rb', line 67

def to_h
  d = {}
  d[:time] = time.to_i if time
  d[:key] = key if key
  d[:value] = value if value
  d[:host] = host if host
  d[:source] = source if source
  d[:state] = state if state
  d[:description] = description if description
  d[:ttl] = ttl if ttl

  if t = tags and not t.empty?
    d[:tags] = t
  end

  if a = attributes and not a.empty?
    d[:attributes] = a
  end

  d
end