Class: LaunchPad::Parser

Inherits:
Object
  • Object
show all
Includes:
LaunchPad
Defined in:
lib/launch-pad/parser.rb

Constant Summary

Constants included from LaunchPad

VERSION

Class Method Summary collapse

Class Method Details

.parse(message) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/launch-pad/parser.rb', line 9

def self.parse(message)
  commands = nil
  
  incoming = YAML::load(message.to_s).symbolize_keys
  
  key = :register
  unless incoming[:unregister].nil?
    key = :unregister
  end
  
  begin
    command = "LaunchPad::#{incoming[key].camelize}".constantize.new(incoming)
  rescue NameError => exception
    raise UndefinedRegistrationException.new exception
  end
  
  command
end