Sha256: 8e8894034ab223c12db8705de8ee2897b48f5d0f3a52c29d4697aac9abc2b09e

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

require 'yaml'
require 'logger'
require 'forwardable'

require "localjob/version"
require 'localjob/worker'
require 'localjob/sysv_adapter'

class Localjob
  extend Forwardable

  attr_reader :name
  attr_accessor :queue

  def_delegators :queue, :to_io, :destroy, :size

  # LOCALJOB in 1337speak
  def initialize(name = 0x10CA110B)
    @name = name
  end

  def serializer
    YAML
  end

  def queue
    @queue ||= SysvAdapter.new(@name)
  end

  def <<(object)
    queue.send serializer.dump(object)
  end

  def shift
    serializer.load queue.receive
  # Bad serialization
  rescue Object
    nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
localjob-0.2.0 lib/localjob.rb