polyrex-objects 0.6.15 → 0.6.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e509e7297265d0bdb8d94a5bc032b4cd0c4f140
4
- data.tar.gz: 7ecdecdc572038e874ddcb3c5c70532cc1788713
3
+ metadata.gz: c097213513006be1ea150bc41039c6cdfb621aba
4
+ data.tar.gz: 870b71afec3bd9397ad22639b4c53d751fadb2ae
5
5
  SHA512:
6
- metadata.gz: 47ca9ca0168f2a6e5d793bfec4f2f150414129bd5178784610db633651b1e7432717348adc002f0bb5a09dea94e372c7da930825bfe944c5790f673551c7ac83
7
- data.tar.gz: 436f77e9e1aa86ca9f4b9aad291979bebef24ef3c01e50a50da5dede82464bda415285d54d2e9c0e7386202a208730310fac5ac9847b3ea542aa830f4e8ccb32
6
+ metadata.gz: c49caf766d73cf470447112bc011edec9d2e68fcae68b997f02accaca13db3cb30a0d8a347332aeed294aa3a881725e8227bbbeb1693969767a20cf9e01098c7
7
+ data.tar.gz: a827acecb23377d7d0fd5b0cb8cf3a17544e86da77f88b5fff77338a08baadc386ff90c3e48edc8a58f5960d0153ca405d2ecc64aa481704a628458a627d00bb
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,13 +9,18 @@ require 'rexle'
9
9
 
10
10
  class PolyrexObjects
11
11
 
12
- class PolyrexObject
13
-
12
+ class PolyrexObject
13
+
14
14
  def initialize(node, id='0')
15
15
  @@id = id
16
16
  @node = node
17
+ @fields =[]
17
18
  end
18
19
 
20
+ def add(pxobj)
21
+ self.create.method(pxobj.class.to_s[/[^:]+$/].downcase).call(pxobj.to_h)
22
+ end
23
+
19
24
  def create(id=nil)
20
25
  id ||= @@id
21
26
  id.succ!
@@ -37,6 +42,12 @@ class PolyrexObjects
37
42
  "#<PolyrexObject:%s" % __id__
38
43
  end
39
44
 
45
+ def to_h()
46
+ @fields.inject({}) do |r, field|
47
+ r.merge(field => self.method(field).call)
48
+ end
49
+ end
50
+
40
51
  def to_xml(options={})
41
52
  @node.xml(options)
42
53
  end
@@ -76,9 +87,11 @@ class PolyrexObjects
76
87
  classx << "yaml_fields.each do |field|"
77
88
  classx << %q(instance_eval "def #{field}; YAML.load(@node.element('summary/#{field}/text()')); end")
78
89
  classx << "end"
79
-
90
+
91
+ classx << "@fields = %i(#{fields.join(' ')})"
80
92
  classx << "@create = PolyrexCreateObject.new('#{schema}', @@id)"
81
93
  classx << "end"
94
+
82
95
  fields.each do |field|
83
96
  classx << "def #{field}"
84
97
  classx << " if @node.element('summary/#{field}').nil? then"
@@ -94,6 +107,7 @@ class PolyrexObjects
94
107
  classx << " end"
95
108
  classx << "end"
96
109
  end
110
+
97
111
  classx << "end"
98
112
 
99
113
  eval classx.join("\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.15
4
+ version: 0.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  JMWS3MnEwxE/NLM3D1lV0gz1tVeyaJfaGg4M23ZLHbcE6P9LF2fV3LIRxDJlUeUB
30
30
  DdZHtSzrIZNGkcDlh1ea0JRmUxIv1wrk
31
31
  -----END CERTIFICATE-----
32
- date: 2013-12-19 00:00:00.000000000 Z
32
+ date: 2014-01-03 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: polyrex-createobject
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.0.0.rc.2
75
+ rubygems_version: 2.1.11
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: polyrex-objects
metadata.gz.sig CHANGED
Binary file