Class: Jets::Shim::Handler
- Inherits:
-
Object
- Object
- Jets::Shim::Handler
- Extended by:
- Util::Logging
- Includes:
- Util::Logging
- Defined in:
- lib/jets/shim/handler.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
-
.show_debug_shim(message, payload) ⇒ Object
interface method used by Shim::Response::Base.
Instance Method Summary collapse
- #adapter ⇒ Object
- #handle ⇒ Object
-
#initialize(event, context = nil, target = nil) ⇒ Handler
constructor
A new instance of Handler.
Methods included from Util::Logging
Constructor Details
#initialize(event, context = nil, target = nil) ⇒ Handler
Returns a new instance of Handler.
6 7 8 9 10 |
# File 'lib/jets/shim/handler.rb', line 6 def initialize(event, context = nil, target = nil) @event = event.deep_stringify_keys @context = context @target = target # IE: cool_event.party end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/jets/shim/handler.rb', line 5 def context @context end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/jets/shim/handler.rb', line 5 def event @event end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/jets/shim/handler.rb', line 5 def target @target end |
Class Method Details
.show_debug_shim(message, payload) ⇒ Object
interface method used by Shim::Response::Base
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jets/shim/handler.rb', line 46 def show_debug_shim(, payload) return unless ENV["JETS_DEBUG_SHIM"] log.info # pretty mode is not useful on CloudWatch since it strips the surrounding spaces on each line # It's only useful for testing handlers locally if ENV["JETS_DEBUG_SHIM"] == "pretty" log.info JSON.pretty_generate(payload) else log.info JSON.dump(payload) # json one line end end |
Instance Method Details
#adapter ⇒ Object
17 18 19 20 21 |
# File 'lib/jets/shim/handler.rb', line 17 def adapter adapter_class = Adapter.const_get(adapter_name.to_s.camelize) log.info "jets shim adapter: #{adapter_name}" if ENV["JETS_DEBUG_SHIM"] adapter_class.new(event, context, target) # IE: Adapter::Apigw end |
#handle ⇒ Object
12 13 14 15 |
# File 'lib/jets/shim/handler.rb', line 12 def handle show_debug_shim_event adapter.handle end |