Sha256: 030330810fe72462103871ed674e4a8c2628507056c3e772dedb190419c850ed
Contents?: true
Size: 728 Bytes
Versions: 4
Compression:
Stored size: 728 Bytes
Contents
module Alondra class ListenerCallback attr_reader :event_type attr_reader :options attr_reader :proc CHANNEL_NAME_PATTERN = %r{\d+$} def initialize(event_type, options = {}, proc) @event_type = event_type @options = options @proc = proc end def matches?(event) return false unless event.type == event_type case options[:to] when nil then true when :member then member_channel? event.channel_name when :collection then !member_channel?(event.channel_name) end end def to_proc proc end private def member_channel?(channel_name) channel_name =~ CHANNEL_NAME_PATTERN end end end
Version data entries
4 entries across 4 versions & 1 rubygems