Sha256: fa0f9e9a905b93b8ccd2baf6cec9152dd3d010cfe8cc86103e669c20060aa55a
Contents?: true
Size: 1021 Bytes
Versions: 3
Compression:
Stored size: 1021 Bytes
Contents
# frozen_string_literal: true require 'active_support' # Controller helper concern module AwsCron module Controller extend ActiveSupport::Concern # Runs block and ensures error logging and proper JSON return def run(&block) yield rescue => exception AwsCron::log(:error, exception) ensure self.return_object end # Runs block using defined timezone for cron scheduling # and ensures error logging and proper JSON return # # For tasks that call this method, make sure to have # cron.yaml call this task in way that allows it to # check programmatically if it needs to be triggered def run_in_tz(cron_str, &block) run do CronRunner.new(cron_str, time_provider).run do yield end end end protected def return_object raise SecurityError('You must implement return_object with a 200 HTTP response using your preferred web framework') end def time_provider Time end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aws_cron-0.1.3 | lib/aws_cron/controller.rb |
aws_cron-0.1.2 | lib/aws_cron/controller.rb |
aws_cron-0.1.1 | lib/aws_cron/controller.rb |