class LambdaPunch::Notifier

Constants

FILE

Public Class Methods

handled!(context) click to toggle source
# File lib/lambda_punch/notifier.rb, line 8
def handled!(context)
  File.open(FILE, 'w') do |f|
    f.write context.aws_request_id
  end
end
new() click to toggle source
# File lib/lambda_punch/notifier.rb, line 20
def initialize
  @notifier = INotify::Notifier.new
  File.open(FILE, 'w') { |f| f.write('') } unless File.exist?(FILE)
end
request_id() click to toggle source
# File lib/lambda_punch/notifier.rb, line 14
def request_id
  File.read(FILE)
end

Public Instance Methods

close() click to toggle source
# File lib/lambda_punch/notifier.rb, line 33
def close
  logger.debug "Notifier#close"
  @notifier.close rescue true
end
process() click to toggle source
# File lib/lambda_punch/notifier.rb, line 29
def process
  @notifier.process
end
request_id() click to toggle source
# File lib/lambda_punch/notifier.rb, line 38
def request_id
  self.class.request_id
end
watch() { |request_id| ... } click to toggle source
# File lib/lambda_punch/notifier.rb, line 25
def watch
  @notifier.watch(FILE, :modify, :oneshot) { yield(request_id) }
end

Private Instance Methods

logger() click to toggle source
# File lib/lambda_punch/notifier.rb, line 44
def logger
  LambdaPunch.logger
end