Class: Alondra::ListenerCallback
- Inherits:
-
Object
- Object
- Alondra::ListenerCallback
- Defined in:
- lib/alondra/listener_callback.rb
Constant Summary collapse
- CHANNEL_NAME_PATTERN =
%r{\d+$}
Instance Attribute Summary collapse
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
-
#initialize(event_type, options = {}, proc) ⇒ ListenerCallback
constructor
A new instance of ListenerCallback.
- #matches?(event) ⇒ Boolean
- #to_proc ⇒ Object
Constructor Details
#initialize(event_type, options = {}, proc) ⇒ ListenerCallback
Returns a new instance of ListenerCallback.
9 10 11 12 13 |
# File 'lib/alondra/listener_callback.rb', line 9 def initialize(event_type, = {}, proc) @event_type = event_type @options = @proc = proc end |
Instance Attribute Details
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
3 4 5 |
# File 'lib/alondra/listener_callback.rb', line 3 def event_type @event_type end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/alondra/listener_callback.rb', line 4 def @options end |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
5 6 7 |
# File 'lib/alondra/listener_callback.rb', line 5 def proc @proc end |
Instance Method Details
#matches?(event) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/alondra/listener_callback.rb', line 15 def matches?(event) return false unless event.type == event_type case [:to] when nil then true when :member then member_channel? event.channel_name when :collection then !member_channel?(event.channel_name) end end |
#to_proc ⇒ Object
27 28 29 |
# File 'lib/alondra/listener_callback.rb', line 27 def to_proc proc end |