polyrex-createobject 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/polyrex-createobject.rb +9 -7
  2. metadata +2 -2
@@ -3,7 +3,6 @@
3
3
  # file: polyrex-createobject.rb
4
4
 
5
5
  require 'polyrex-schema'
6
- require 'backtrack-xpath'
7
6
  require 'rexml/document'
8
7
 
9
8
  class PolyrexCreateObject
@@ -13,6 +12,7 @@ class PolyrexCreateObject
13
12
 
14
13
  def initialize(schema)
15
14
 
15
+ @id = 1
16
16
  @schema = schema
17
17
  a = @schema.split('/')
18
18
 
@@ -30,9 +30,10 @@ class PolyrexCreateObject
30
30
  def attach_create_handlers(names)
31
31
  methodx = names[0..-2].map do |name, xpath|
32
32
  %Q(
33
- def #{name}(params={}, id=nil)
33
+ def #{name}(params={}, id=nil,&blk)
34
34
  records = XPath.first(@parent_node,'records')
35
- create_node(records, @rpaths['#{xpath}'], params, id)
35
+ self.record = create_node(records, @rpaths['#{xpath}'], params, id)
36
+ blk.call(self) if blk
36
37
  self
37
38
  end
38
39
  )
@@ -41,9 +42,10 @@ class PolyrexCreateObject
41
42
  name, xpath = names[-1]
42
43
 
43
44
  methodx << %Q(
44
- def #{name}(params={}, id=nil)
45
- @parent_node = XPath.first(@parent_node.root,'//records')
46
- record = create_node(@parent_node, @rpaths['#{xpath}'], params, id)
45
+ def #{name}(params={}, id=nil,&blk)
46
+ self.record = XPath.first(@parent_node.root,'records')
47
+ self.record = create_node(@parent_node, @rpaths['#{xpath}'], params, id)
48
+ blk.call(self) if blk
47
49
  self
48
50
  end
49
51
  )
@@ -71,7 +73,7 @@ end
71
73
  end
72
74
 
73
75
  parent_node.add record.root
74
- record
76
+
75
77
  end
76
78
 
77
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex-createobject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-06-09 00:00:00 +01:00
12
+ date: 2010-06-15 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency