Class: Asynchronous::SharedMemory

Inherits:
CleanClass show all
Defined in:
lib/asynchronous/shared_memory.rb

Class Method Summary collapse

Class Method Details

.method_missing(method, *args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/asynchronous/shared_memory.rb', line 25

def method_missing(method, *args)

  ::Asynchronous::Allocation.mutex.synchronize do
    if method.to_s.include?('=')
      begin
        self.class_variable_get("@@#{method.to_s.sub('=','')}").write_object(args[0])
      rescue ::NameError
        self.class_variable_set(
            "@@#{method.to_s.sub('=','')}",
            ::ProcessShared::SharedMemory.new( ::Asynchronous::Allocation.memory_allocation_size )
        )
        self.class_variable_get("@@#{method.to_s.sub('=','')}").write_object(args[0])
      end
    else
      begin
        self.class_variable_get("@@#{method.to_s}").read_object
      rescue ::NameError
        return nil
      end
    end
  end

end