Class: Dizby::DistributedArray

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/distributed/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ary, server) ⇒ DistributedArray

Returns a new instance of DistributedArray.



13
14
15
16
17
18
19
20
21
22
# File 'lib/dizby/distributed/array.rb', line 13

def initialize(ary, server)
  @ary =
    ary.map do |obj|
      if obj.is_a? UndumpableObject
        DistributedObject.new(obj, server)
      else
        self.class.distribute_if_necessary(obj)
      end
    end
end

Class Method Details

._load(str)



32
33
34
# File 'lib/dizby/distributed/array.rb', line 32

def self._load(str)
  Marshal.load(str)
end

.distribute_if_necessary(obj)



24
25
26
27
28
29
30
# File 'lib/dizby/distributed/array.rb', line 24

def self.distribute_if_necessary(obj)
  Marshal.dump(obj)
rescue
  DistributedObject.new(obj, server)
else
  obj
end

Instance Method Details

#_dump(_)



36
37
38
# File 'lib/dizby/distributed/array.rb', line 36

def _dump(_)
  Marshal.dump(@ary)
end