Class: FWC::Matcher

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Matcher

Returns a new instance of Matcher.



200
201
202
203
# File 'lib/fwc.rb', line 200

def initialize opts={}
  @key = opts[:key]
  @tags = opts[:tags]
end

Instance Method Details

#matches?(data) ⇒ Boolean

Returns:

  • (Boolean)


205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/fwc.rb', line 205

def matches? data
  return false unless ["event", "metric"].include? data["type"]

  d = data["data"]
  return false unless d

  key = d["key"]
  return false if @key and @key != key

  tags = d["tags"]
  return false if @tags and (@tags & (tags || [])).empty?

  true
end