dina 0.7.3.0 → 0.7.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dina/casters/multilingual_description.rb +7 -22
- data/lib/dina/casters/multilingual_description_caster.rb +1 -1
- data/lib/dina/casters/multilingual_title.rb +7 -22
- data/lib/dina/casters/multilingual_title_caster.rb +1 -1
- data/lib/dina/exceptions.rb +1 -0
- data/lib/dina/models/base_model.rb +27 -5
- data/lib/dina/models/managed_attribute.rb +0 -16
- data/lib/dina/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620e59a87be3c3adb55fba2d7d4084a12fbb12a78427ca53de33426ae8510110
|
4
|
+
data.tar.gz: 6c2c5daff310c35f43b165156fc06944d44e4a74db84da12af055fb4d0be401d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5913b6fe291bbcb26b4c5bf298bf4f6307077e006442952ad1937833952074728352cc1f0e1e01a6abfa8f5197b06161ddf1ef674dc29a4012761f46ed231a
|
7
|
+
data.tar.gz: dea42bb62339358120b3d890edd22727c81058e30e6b9b3c7443d90e515e10942a12533bc94e52b5d8a6a8578d1ba67e70e6c4e1366672c828a789c1bace37e0
|
@@ -6,31 +6,16 @@ module Dina
|
|
6
6
|
@descriptions = []
|
7
7
|
if opts[:descriptions]
|
8
8
|
@descriptions = opts[:descriptions]
|
9
|
-
|
10
|
-
|
11
|
-
self.english_description = opts[:english]
|
12
|
-
end
|
13
|
-
if opts[:french]
|
14
|
-
self.french_description = opts[:french]
|
9
|
+
else
|
10
|
+
self.set_description(opts)
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def english_description
|
24
|
-
descriptions.select{|o| o[:lang] == "en"}.first[:desc]
|
25
|
-
end
|
26
|
-
|
27
|
-
def french_description=(desc)
|
28
|
-
descriptions.delete_if{|o| o[:lang] == "fr"}
|
29
|
-
descriptions << { lang: "fr", desc: desc }
|
30
|
-
end
|
31
|
-
|
32
|
-
def french_description
|
33
|
-
descriptions.select{|o| o[:lang] == "fr"}.first[:desc]
|
14
|
+
def set_description(opts = {})
|
15
|
+
opts.each do |key, value|
|
16
|
+
descriptions.delete_if{|o| o[:lang] == key.to_s}
|
17
|
+
descriptions << { lang: key.to_s, desc: value }
|
18
|
+
end
|
34
19
|
end
|
35
20
|
|
36
21
|
def to_hash
|
@@ -6,31 +6,16 @@ module Dina
|
|
6
6
|
@titles = []
|
7
7
|
if opts[:titles]
|
8
8
|
@titles = opts[:titles]
|
9
|
-
|
10
|
-
|
11
|
-
self.english_title = opts[:english]
|
12
|
-
end
|
13
|
-
if opts[:french]
|
14
|
-
self.french_title = opts[:french]
|
9
|
+
else
|
10
|
+
self.set_title(opts)
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def english_title
|
24
|
-
titles.select{|o| o[:lang] == "en"}.first[:title]
|
25
|
-
end
|
26
|
-
|
27
|
-
def french_title=(title)
|
28
|
-
titles.delete_if{|o| o[:lang] == "fr"}
|
29
|
-
titles << { lang: "fr", title: title }
|
30
|
-
end
|
31
|
-
|
32
|
-
def french_title
|
33
|
-
titles.select{|o| o[:lang] == "fr"}.first[:title]
|
14
|
+
def set_title(opts ={})
|
15
|
+
opts.each do |key, value|
|
16
|
+
titles.delete_if{|o| o[:lang] == key.to_s}
|
17
|
+
titles << { lang: key.to_s, title: value }
|
18
|
+
end
|
34
19
|
end
|
35
20
|
|
36
21
|
def to_hash
|
data/lib/dina/exceptions.rb
CHANGED
@@ -40,15 +40,37 @@ module Dina
|
|
40
40
|
super
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
# Adds or updates a multilingualDescription with a language key
|
44
|
+
#
|
45
|
+
# @param opts [Hash] the description expessed as { en: "My description" }
|
46
|
+
def set_multilingualDescription(opts = {})
|
44
47
|
if self.respond_to?(:multilingualDescription)
|
45
|
-
multilingualDescription
|
48
|
+
if self.multilingualDescription.nil?
|
49
|
+
self.multilingualDescription = opts
|
50
|
+
else
|
51
|
+
descriptions = multilingualDescription["descriptions"]
|
52
|
+
descriptions.delete_if{|o| o["lang"] == opts.keys[0].to_s}
|
53
|
+
descriptions << { "lang" => opts.keys[0].to_s, "desc" => opts[opts.keys[0]] }
|
54
|
+
end
|
55
|
+
else
|
56
|
+
raise PropertyInvalid, "#{self.class} does not have the property multilingualDescription"
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
|
60
|
+
# Adds or updates a multilingualTitle with a language key
|
61
|
+
#
|
62
|
+
# @param opts [Hash] the title expessed as { en: "My title" }
|
63
|
+
def set_multilingualTitle(opts = {})
|
64
|
+
if self.respond_to?(:multilingualTitle)
|
65
|
+
if self.multilingualTitle.nil?
|
66
|
+
self.multilingualTitle = opts
|
67
|
+
else
|
68
|
+
titles = multilingualTitle["titles"]
|
69
|
+
titles.delete_if{|o| o["lang"] == opts.keys[0].to_s}
|
70
|
+
titles << { "lang" => opts.keys[0].to_s, "title" => opts[opts.keys[0]] }
|
71
|
+
end
|
72
|
+
else
|
73
|
+
raise PropertyInvalid, "#{self.class} does not have the property multilingualTitle"
|
52
74
|
end
|
53
75
|
end
|
54
76
|
|
@@ -46,22 +46,6 @@ module Dina
|
|
46
46
|
]
|
47
47
|
end
|
48
48
|
|
49
|
-
def english_description=(desc)
|
50
|
-
description[:en] = desc
|
51
|
-
end
|
52
|
-
|
53
|
-
def english_description
|
54
|
-
description[:en]
|
55
|
-
end
|
56
|
-
|
57
|
-
def french_description=(desc)
|
58
|
-
description[:fr] = desc
|
59
|
-
end
|
60
|
-
|
61
|
-
def french_description
|
62
|
-
description[:fr]
|
63
|
-
end
|
64
|
-
|
65
49
|
private
|
66
50
|
|
67
51
|
def on_before_save
|
data/lib/dina/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David P. Shorthouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|