Class: Eventually::Validation::MaxListeners
- Inherits:
-
Object
- Object
- Eventually::Validation::MaxListeners
- Defined in:
- lib/eventually/validation/max_listeners.rb
Instance Method Summary collapse
-
#initialize(emitter) ⇒ MaxListeners
constructor
A new instance of MaxListeners.
- #valid? ⇒ Boolean
- #warn_unless_valid! ⇒ Object
Constructor Details
#initialize(emitter) ⇒ MaxListeners
Returns a new instance of MaxListeners.
4 5 6 |
# File 'lib/eventually/validation/max_listeners.rb', line 4 def initialize(emitter) @emitter = emitter end |
Instance Method Details
#valid? ⇒ Boolean
8 9 10 |
# File 'lib/eventually/validation/max_listeners.rb', line 8 def valid? @emitter.class.max_listeners == 0 || @emitter.num_listeners <= @emitter.class.max_listeners end |
#warn_unless_valid! ⇒ Object
12 13 14 |
# File 'lib/eventually/validation/max_listeners.rb', line 12 def warn_unless_valid! puts "Warning: #{@emitter.class.name} has more than #{@emitter.class.max_listeners} registered listeners." unless valid? end |