dynarex 1.0.15 → 1.0.16

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/dynarex.rb +4 -6
  2. metadata +2 -2
@@ -143,7 +143,7 @@ EOF
143
143
  end
144
144
 
145
145
  # if records already exist find the max id
146
- i = @doc.xpath('records/*/attribute::id').max_by(&:value).to_s.to_i
146
+ i = @doc.xpath('max(records/*/attribute::id)').to_i
147
147
 
148
148
 
149
149
  # 'a' and 'a_split' just used for validation
@@ -205,6 +205,7 @@ EOF
205
205
  # dynarex.create name: Bob, age: 52
206
206
 
207
207
  def create(arg, id=nil)
208
+
208
209
  methods = {Hash: :hash_create, String: :create_from_line}
209
210
  send (methods[arg.class.to_s.to_sym]), arg, id
210
211
 
@@ -299,11 +300,8 @@ EOF
299
300
  element.text = v if v
300
301
  record.add element
301
302
  end
302
-
303
- unless id
304
- ids = @doc.xpath('records/*/attribute::id').map(&:to_i)
305
- id = ids.empty? ? (id || 1) : ids.max.succ
306
- end
303
+
304
+ id = (@doc.xpath('max(records/*/attribute::id)').to_i + 1).to_s unless id
307
305
 
308
306
  attributes = {id: id, created: Time.now.to_s, last_modified: nil}
309
307
  attributes.each {|k,v| record.add_attribute(k, v)}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
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: 2011-02-11 00:00:00 +00:00
12
+ date: 2011-02-12 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency