Class: MingleEvents::Processors::CardTypeFilter

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

Overview

Filters events by card types. As events do not contain the type of the card, 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(card_types, card_data) ⇒ CardTypeFilter

Returns a new instance of CardTypeFilter.



13
14
15
16
# File 'lib/mingle_events/processors/card_type_filter.rb', line 13

def initialize(card_types, card_data)
  @card_types = card_types
  @card_data = card_data
end

Instance Method Details

#match?(event) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/mingle_events/processors/card_type_filter.rb', line 18

def match?(event)
  event.card? &&
    @card_data.for_card_event(event) &&
    @card_types.include?(@card_data.for_card_event(event)[:card_type_name])
end