Class: Jets::Shim::Adapter::Event

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/shim/adapter/event.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #event, #target

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Util::Logging

#log

Constructor Details

This class inherits a constructor from Jets::Shim::Adapter::Base

Instance Method Details

#handleObject



3
4
5
# File 'lib/jets/shim/adapter/event.rb', line 3

def handle
  target_class.handle(event, context, target_method)
end

#handle?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/jets/shim/adapter/event.rb', line 7

def handle?
  target && target_class && target_method?
end

#target_classObject



11
12
13
14
15
# File 'lib/jets/shim/adapter/event.rb', line 11

def target_class
  class_name, _ = target.split(".")
  class_name.camelize.constantize
rescue NameError
end

#target_methodObject



17
18
19
20
21
# File 'lib/jets/shim/adapter/event.rb', line 17

def target_method
  _, method_name = target.split(".")
  method_name ||= "perform"
  method_name.to_sym
end

#target_method?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/jets/shim/adapter/event.rb', line 23

def target_method?
  target_class.public_instance_methods.include?(target_method)
end