Module: Controll::Event::Helper

Instance Method Summary collapse

Instance Method Details

#create_event(name, *args) ⇒ Object



16
17
18
# File 'lib/controll/event/helper.rb', line 16

def create_event name, *args
  Controll::Event.new name, *args
end

#normalize(event, *args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/controll/event/helper.rb', line 3

def normalize event, *args
  case event
  when Controll::Event
    event
  when Symbol, String
    create_event event.to_sym, *args
  when Hash, Hashie::Mash
    create_event event.delete(:name), event
  else
    raise Controll::Event::InvalidError, "Event: #{event} could not be normalized, must be a Hash, String or Symbol"
  end
end