recordx 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/recordx.rb +13 -7
- metadata +1 -1
data/lib/recordx.rb
CHANGED
@@ -5,15 +5,21 @@
|
|
5
5
|
class RecordX
|
6
6
|
|
7
7
|
def initialize(callerx, id, h={})
|
8
|
+
@callerx, @id = callerx, id
|
9
|
+
h.each {|name,val| attr_accessor2(name.to_s, val) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method_name, *raw_args)
|
13
|
+
arg = raw_args.length > 0 ? raw_args.first : nil
|
14
|
+
attr_accessor2(method_name[/\w+/], arg)
|
15
|
+
arg ? self.send(method_name, arg) : self.send(method_name)
|
16
|
+
end
|
8
17
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
name, val = k.to_s, v
|
13
|
-
"def #{name}=(s) @#{name} = s.to_s; @callerx.update(@id, #{name}: s.to_s) end\n\
|
18
|
+
def attr_accessor2(name,val=nil)
|
19
|
+
self.instance_eval "def #{name}=(s)\n @#{name} = s.to_s\n\
|
20
|
+
@callerx.update(@id, #{name}: s.to_s)\n end\n\
|
14
21
|
def #{name}() @#{name} end\n\
|
15
22
|
@#{name} = '#{val}'"
|
16
|
-
end
|
17
|
-
self.instance_eval methods.join("\n")
|
18
23
|
end
|
24
|
+
|
19
25
|
end
|