Class: MingleEvents::Processors::CustomPropertyFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/mingle_events/processors/custom_property_filter.rb

Overview

Filters events by a single custom property value. As events will not necessarily contain this data, this filter requires a lookup against Mingle to determine the type of the card that sourced the event. In the case of the card’s being deleted in the interim between the actual event and this filtering, the event will be filtered as there is no means to determine its type. Therefore, it’s recommended to also subscribe a ‘CardDeleted’ processor to the same project.

Instance Method Summary collapse

Methods inherited from Filter

#process_events

Constructor Details

#initialize(property_name, property_value, card_data) ⇒ CustomPropertyFilter

Returns a new instance of CustomPropertyFilter.



14
15
16
17
18
# File 'lib/mingle_events/processors/custom_property_filter.rb', line 14

def initialize(property_name, property_value, card_data)
  @property_name = property_name
  @property_value = property_value
  @card_data = card_data
end

Instance Method Details

#match?(event) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/mingle_events/processors/custom_property_filter.rb', line 20

def match?(event)
  event.card? && 
    @card_data.for_card_event(event) &&
    @property_value == @card_data.for_card_event(event)[:custom_properties][@property_name]
end