polyrex-objects 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/polyrex-objects.rb +8 -1
- metadata +1 -1
data/lib/polyrex-objects.rb
CHANGED
@@ -54,13 +54,20 @@ class PolyrexObjects
|
|
54
54
|
classx << "class #{name.capitalize} < PolyrexObject"
|
55
55
|
classx << "def initialize(node=nil, id='0')"
|
56
56
|
classx << "super(node,id)"
|
57
|
+
|
58
|
+
classx << "a = node.xpath('summary/*',&:name)"
|
59
|
+
classx << "yaml_fields = a - (#{fields} + %w(format_mask))"
|
60
|
+
classx << "yaml_fields.each do |field|"
|
61
|
+
classx << %q(instance_eval "def #{field}; YAML.load(@node.element('summary/#{field}/text()')); end")
|
62
|
+
classx << "end"
|
63
|
+
|
57
64
|
classx << "@create = PolyrexCreateObject.new('#{schema}', @@id)"
|
58
65
|
classx << "end"
|
59
66
|
fields.each do |field|
|
60
67
|
classx << "def #{field}; @node.element('summary/#{field}/text()'); end"
|
61
68
|
classx << "def #{field}=(text); @node.element('summary/#{field}').text = text; end"
|
62
69
|
end
|
63
|
-
classx << "end"
|
70
|
+
classx << "end"
|
64
71
|
|
65
72
|
eval classx.join("\n")
|
66
73
|
end
|