Class: Airbrush::Handler

Inherits:
Object show all
Defined in:
lib/airbrush/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor, publisher) ⇒ Handler

Returns a new instance of Handler.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/airbrush/handler.rb', line 5

def initialize(processor, publisher)
  raise ArgumentError, 'no processor specified' unless processor
  raise ArgumentError, 'no publisher specified' unless publisher
  
  @processor = processor
  @publisher = publisher
end

Instance Attribute Details

#processorObject (readonly)

Returns the value of attribute processor.



3
4
5
# File 'lib/airbrush/handler.rb', line 3

def processor
  @processor
end

#publisherObject (readonly)

Returns the value of attribute publisher.



3
4
5
# File 'lib/airbrush/handler.rb', line 3

def publisher
  @publisher
end

Instance Method Details

#process(id, command, args) ⇒ Object



13
14
15
# File 'lib/airbrush/handler.rb', line 13

def process(id, command, args)
  @publisher.publish id, @processor.dispatch(command, args)
end