25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/interprocess_attribute.rb', line 25
def interprocess_attribute(name, opts = {visibility: "public"})
class_eval do
channel = IChannel.new Marshal
define_method name do
while channel.readable?
instance_variable_set "@#{name}", channel.get
end
instance_variable_get "@#{name}"
end
send opts[:visibility], name.to_sym
define_method "#{name}=" do |value|
channel.put value
instance_variable_set "@#{name}", value
end
send opts[:visibility], "#{name}=".to_sym
end
end
|