Project

General

Profile

Bug #7714 ยป ruby-doc_drb-20130117.patch

vbatts (Vincent Batts), 01/18/2013 03:38 PM

View differences:

lib/drb/drb.rb
426 426

  
427 427
  # An exception wrapping an error object
428 428
  class DRbRemoteError < DRbError
429
    # Create a new DRb::DRbRemoteError
429 430
    def initialize(error)
430 431
      @reason = error.class.to_s
431 432
      super("#{error.message} (#{error.class})")
......
505 506
    end
506 507
  end
507 508

  
509
  # Class to wrap an Array.
510
  #
511
  # === Description
512
  #
513
  # A DRbArray can be provided in a DRb call. When the marshalled value
514
  # of a DRbArray object is unmarshalled, it returns the wrapped Array.
515
  #
516
  #
517
  # === Examples
518
  #
519
  #   a = %w{ cats and dogs }
520
  #   => ["cats", "and", "dogs"]
521
  #   da = DRb::DRbArray.new(a)
522
  #   => #<DRb::DRbArray:0x0000000068b0f0 @ary=["cats", "and", "dogs"]>
523
  #   bin = Marshal.dump(h)
524
  #   => "\x04\bu:\x12DRb::DRbArray*\x04\b[\bI\"\tcats\x06:\x06ETI\"\band\x06;\0TI\"\tdogs\x06;\0T"
525
  #   Marshal.load(bin)
526
  #   => ["cats", "and", "dogs"]
527
  #
508 528
  class DRbArray
529
    # Create a DRb::DRbArray object
530
    #
531
    # +ary+ is an Array
509 532
    def initialize(ary)
510 533
      @ary = ary.collect { |obj|
511 534
        if obj.kind_of? DRbUndumped
......
521 544
      }
522 545
    end
523 546

  
524
    def self._load(s)
547
    def self._load(s) # :nodoc:
525 548
      Marshal::load(s)
526 549
    end
527 550

  
528
    def _dump(lv)
551
    def _dump(lv) # :nodoc:
529 552
      Marshal.dump(@ary)
530 553
    end
531 554
  end
......
629 652
    end
630 653

  
631 654
    private
632
    def make_proxy(obj, error=false)
655
    def make_proxy(obj, error=false) # :nodoc:
633 656
      if error
634 657
        DRbRemoteError.new(obj)
635 658
      else
......
1008 1031
      self.new_with(uri, ref)
1009 1032
    end
1010 1033

  
1034
    # Create a DRb::DRbObject given the reference information to the
1035
    # remote host uri String, and ref
1011 1036
    def self.new_with(uri, ref)
1012 1037
      it = self.allocate
1013 1038
      it.instance_variable_set(:@uri, uri)
......
1731 1756
  # Set the default acl.
1732 1757
  #
1733 1758
  # See DRb::DRbServer.default_acl.
1759
  # XXX needs more info
1734 1760
  def install_acl(acl)
1735 1761
    DRbServer.default_acl(acl)
1736 1762
  end
1737 1763
  module_function :install_acl
1738 1764

  
1739 1765
  @mutex = Mutex.new
1766
  # Get the semaphore for this DRb module
1767
  #
1768
  # return's a Mutex instance
1740 1769
  def mutex
1741 1770
    @mutex
1742 1771
  end
1743 1772
  module_function :mutex
1744 1773

  
1745 1774
  @server = {}
1775
  # Recored the DRb::DRbServer +server+
1776
  #
1777
  # This is called when a new DRb::DRbServer instance is created.
1778
  #
1779
  #   require 'drb'
1780
  #
1781
  #   s = DRb::DRbServer.new
1782
  #   => #<DRb::DRbServer:0x00000001dcb440 @config={:idconv=>#<DRb::...
1783
  #   DRb.fetch_server(s.uri)
1784
  #   => #<DRb::DRbServer:0x00000001dcb440 @config={:idconv=>#<DRb::...
1785
  #
1746 1786
  def regist_server(server)
1747 1787
    @server[server.uri] = server
1748 1788
    mutex.synchronize do
......
1751 1791
  end
1752 1792
  module_function :regist_server
1753 1793

  
1794
  # Remove the DRb::DRbServer +server+ from the registered list
1754 1795
  def remove_server(server)
1755 1796
    @server.delete(server.uri)
1756 1797
  end
1757 1798
  module_function :remove_server
1758 1799

  
1800
  # Return the DRb::DRbServer object, provided the String +uri+.
1801
  #
1802
  # This is provided from the registered servers.
1803
  # See also #regist_server and #remove_server
1759 1804
  def fetch_server(uri)
1760 1805
    @server[uri]
1761 1806
  end