dynarex 1.5.19 → 1.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dynarex.rb +9 -9
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0b78912fbc7d5647bb9713fefae327994e81e07
|
4
|
+
data.tar.gz: 7e0188b5efbc0b751c79d4cbde50f10758ca0259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035f2f7176804545ec9197310bdce7154016cbf5db24fb9b65e1e94f79fee46c79b01f2e4c18f7797cde23495d90edb983ab07c53004051a178b1daa485adf5a
|
7
|
+
data.tar.gz: 4b6041cbf1efaff62aefdfaa0559ea3161e22a068ff7716cf1378112c61ec1b3fec7d28c20ea3327da6681fab9e83d041c326972cde360c41f1f826de5c002a4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dynarex.rb
CHANGED
@@ -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
metadata.gz.sig
CHANGED
Binary file
|