Class: Alfred::Handler::Controller
- Inherits:
-
Object
- Object
- Alfred::Handler::Controller
- Includes:
- Enumerable
- Defined in:
- lib/alfred/handler.rb
Instance Method Summary collapse
- #each ⇒ Object
- #each_handler ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #register(handler) ⇒ Object
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
100 101 102 103 |
# File 'lib/alfred/handler.rb', line 100 def initialize @handlers = SortedSet.new @status = {:break => [:break, :exclusive]} end |
Instance Method Details
#each ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/alfred/handler.rb', line 114 def each return enum_for(__method__) unless block_given? @handlers.each do |h| yield(h) end end |
#each_handler ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/alfred/handler.rb', line 122 def each_handler return enum_for(__method__) unless block_given? @handlers.each do |h| yield(h) break if @status[:break].include?(h.status) end end |
#empty? ⇒ Boolean
110 111 112 |
# File 'lib/alfred/handler.rb', line 110 def empty? @handlers.empty? end |
#register(handler) ⇒ Object
105 106 107 108 |
# File 'lib/alfred/handler.rb', line 105 def register(handler) raise InvalidArgument unless handler.is_a? ::Alfred::Handler::Base @handlers.add(handler) end |