dynarex 1.5.19 → 1.5.20

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: 5412b392093ede04ff5061ae7c4e97a82a1b3c93
4
- data.tar.gz: d8e04e710ae9180f73905598facdedd7c94bdf08
3
+ metadata.gz: f0b78912fbc7d5647bb9713fefae327994e81e07
4
+ data.tar.gz: 7e0188b5efbc0b751c79d4cbde50f10758ca0259
5
5
  SHA512:
6
- metadata.gz: 7cfd1f2b63e4dae8648703147b5947729652710b74cbb22cc7ea21af7e87b88c04f6cdf74c3290ef76aed0e34057cd4b74fd6d6292ac782ca148ef7daba08dca
7
- data.tar.gz: 22828e1113885ed6eb297095f9d93b301feeba8f98445222b66b5ccc366bd9625189a4106eb8baf24d4a32e20db91cf2654cad45708dd59d18058f9cfe6cb5cd
6
+ metadata.gz: 035f2f7176804545ec9197310bdce7154016cbf5db24fb9b65e1e94f79fee46c79b01f2e4c18f7797cde23495d90edb983ab07c53004051a178b1daa485adf5a
7
+ data.tar.gz: 4b6041cbf1efaff62aefdfaa0559ea3161e22a068ff7716cf1378112c61ec1b3fec7d28c20ea3327da6681fab9e83d041c326972cde360c41f1f826de5c002a4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -331,11 +331,12 @@ EOF
331
331
  # dynarex = Dynarex.new 'contacts/contact(name,age,dob)'
332
332
  # dynarex.create name: Bob, age: 52
333
333
 
334
- def create(arg, id=nil)
334
+ def create(arg, id=nil, custom_attributes: {})
335
+
335
336
  raise 'Dynarex#create(): input error: no arg provided' unless arg
336
337
 
337
338
  methods = {Hash: :hash_create, String: :create_from_line}
338
- send (methods[arg.class.to_s.to_sym]), arg, id
339
+ send (methods[arg.class.to_s.to_sym]), arg, id, attr: custom_attributes
339
340
 
340
341
  @dirty_flag = true
341
342
 
@@ -346,7 +347,7 @@ EOF
346
347
  # dynarex = Dynarex.new 'contacts/contact(name,age,dob)'
347
348
  # dynarex.create_from_line 'Tracy 37 15-Jun-1972'
348
349
 
349
- def create_from_line(line, id=nil)
350
+ def create_from_line(line, id=nil, attr: '')
350
351
  t = @format_mask.to_s.gsub(/\[!(\w+)\]/, '(.*)').sub(/\[/,'\[').sub(/\]/,'\]')
351
352
  line.match(/#{t}/).captures
352
353
 
@@ -612,9 +613,9 @@ EOF
612
613
  h[:id], h[:created], h[:last_modified])
613
614
  end
614
615
 
615
- def hash_create(raw_params={}, id=nil)
616
+ def hash_create(raw_params={}, id=nil, attr: {})
616
617
 
617
- record = make_record(raw_params,id)
618
+ record = make_record(raw_params, id, attr: attr)
618
619
  method_name = @order == 'ascending' ? :add : :prepend
619
620
  @doc.root.element('records').method(method_name).call record
620
621
 
@@ -638,7 +639,7 @@ EOF
638
639
  end
639
640
  end
640
641
 
641
- def make_record(raw_params, id=nil)
642
+ def make_record(raw_params, id=nil, attr: {})
642
643
 
643
644
  id = (@doc.root.xpath('max(records/*/attribute::id)') || '0').succ unless id
644
645
  raw_params.merge!(uid: id) if @default_key.to_sym == :uid
@@ -653,9 +654,8 @@ EOF
653
654
  record.add element if record
654
655
  end
655
656
 
656
-
657
-
658
- attributes = {id: id.to_s, created: Time.now.to_s, last_modified: nil}
657
+ attributes = {id: id.to_s, created: Time.now.to_s, last_modified: nil}\
658
+ .merge attr
659
659
  attributes.each {|k,v| record.add_attribute(k, v)}
660
660
 
661
661
  record
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.5.19
4
+ version: 1.5.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file