Sha256: 3579bace567930ec4af845c77f55a11c852b108c1eeae2aee4877106be21351a

Contents?: true

Size: 817 Bytes

Versions: 6

Compression:

Stored size: 817 Bytes

Contents

module Daemonizer
  class Handler
    attr_accessor :worker_id
    attr_accessor :workers_count
    attr_accessor :logger
    
    def initialize(options = {})
      @options = options
    end
    
    def before_init(block)
      block.call
    end
    
    def option(key)
      if option = @options[key.to_sym]
        option.value(self)
      else
        nil
      end
    end
  end
  
  class FakeHandler < Handler
    def initialize(before_init, after_init, options = {})
      @before_init = before_init
      @after_init = after_init
      super(options)
    end
    
    def before_init(block)
      if @before_init
        @before_init.call(@logger, block)
      else
        super
      end
    end
        
    def after_init
      @after_init.call(@logger, @worker_id, @workers_count)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
daemonizer-0.1.6 lib/daemonizer/handler.rb
daemonizer-0.1.5 lib/daemonizer/handler.rb
daemonizer-0.1.4 lib/daemonizer/handler.rb
daemonizer-0.1.3 lib/daemonizer/handler.rb
daemonizer-0.1.2 lib/daemonizer/handler.rb
daemonizer-0.1.1 lib/daemonizer/handler.rb