Sha256: f701d727cb40f7f323a4a56468ddcc0066376980de9c384e8a6d2a174c18b155

Contents?: true

Size: 746 Bytes

Versions: 3

Compression:

Stored size: 746 Bytes

Contents

module FireAndForget
  module Daemon # need better name!

    def self.[](task_name)
      m = Module.new do
        def self.included(klass)
          FireAndForget.map_pid(self.task_name, $$)
        rescue Errno::ECONNREFUSED
          # server isn't running but we don't want this to stop our script
        end

        def self.task_name=(task_name)
          @@task_name = task_name
        end

        def self.task_name
          @@task_name
        end

        def set_task_status(status)
          FireAndForget.set_status(@@task_name, status)
        rescue Errno::ECONNREFUSED
          # server isn't running but we don't want this to stop our script
        end
      end
      m.task_name = task_name
      m
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fire_and_forget-0.1.2 lib/fire_and_forget/daemon.rb
fire_and_forget-0.1.1 lib/fire_and_forget/daemon.rb
fire_and_forget-0.1.0 lib/fire_and_forget/daemon.rb