Class: Alfred::Handler::Controller

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/alfred/handler.rb

Instance Method Summary collapse

Constructor Details

#initializeController

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

#eachObject



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_handlerObject



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

Returns:

  • (Boolean)


110
111
112
# File 'lib/alfred/handler.rb', line 110

def empty?
  @handlers.empty?
end

#register(handler) ⇒ Object

Raises:



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