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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/asynchronous/shared_memory.rb', line 90

def method_missing(method, *args)

  case true

    when method.to_s.include?('=')

      @@static_variables ||= ::Asynchronous::MemoryObj.new(Array.new.push(:static_variables))
      if @@static_variables.include?(method.to_s.sub!('=','').to_sym)
        $stdout.puts "Warning! static varieble cant be changed without removing from the Asynchronous.static_variables array collection (sym)"
        return nil
      else

        begin
          self.class_variable_get("@@#{method.to_s.sub('=','')}").asynchronous_set_value= args[0]
        rescue ::NameError
          self.class_variable_set(
              "@@#{method.to_s.sub('=','')}",
              ::Asynchronous::MemoryObj.new(args[0]))
        end

      end

    else
      begin
        self.class_variable_get("@@#{method.to_s}")
      rescue ::NameError
        return nil
      end
  end

end