Sha256: a5654553d1f977281620b18ff2fea248b9090086f53ba5732efbcaf66a7c5045

Contents?: true

Size: 535 Bytes

Versions: 8

Compression:

Stored size: 535 Bytes

Contents

require 'slave'
#
# if certain operations need to take place in the child only a block can be
# used
#
  class Server
    def connect_to_db 
      "we only want to do this in the child process!"
      @connection = :postgresql
    end
    attr :connection
  end

  slave = Slave.new('object' => Server.new){|s| s.connect_to_db}

  server = slave.object

  p server.connection  #=> :postgresql 
#
# errors in the child are detected and raised in the parent
#
  slave = Slave.new('object' => Server.new){|s| s.typo} #=> raises an error!

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
slave-1.3.2 samples/b.rb
slave-1.3.1 samples/b.rb
slave-1.3.0 samples/b.rb
slave-1.2.2 samples/b.rb
slave-1.0.0 samples/b.rb
slave-1.1.0 samples/b.rb
slave-1.2.0 samples/b.rb
slave-1.2.1 samples/b.rb