dina 0.7.4.0 → 0.7.5.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/models/base_model.rb +6 -30
- data/lib/dina/utils/multi_lingual_description.rb +18 -0
- data/lib/dina/utils/multi_lingual_title.rb +18 -0
- data/lib/dina/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ccd7e97e13338d74abe532c9682da8c190428a6a49e9f185ab8b8ced6ac31ac
|
4
|
+
data.tar.gz: 65fbba40026990fd8cfaa90803e8c909dc3431eea4585800093d9c433801bb25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a13c0b80dea86b275fa961cb0f6c17d7645c5a0ed99fc09b6dbbe087923aa6dc95dcc746bc3ebbdfe26f4200f7486fb94355295ea1ead24a632bcebebf5a233
|
7
|
+
data.tar.gz: 1b4fc2d14a4766fbd598cec301c4e39c002e044e34c70b6a6c48fe4852539e00775def68611a1197807e932de23802a9a568abceb76a04f2907d7405dcf09d74
|
@@ -38,44 +38,20 @@ module Dina
|
|
38
38
|
symbolized_params = params.transform_keys(&:to_sym)
|
39
39
|
params["id"] = SecureRandom.uuid if !symbolized_params[:id]
|
40
40
|
super
|
41
|
+
extend_model_methods
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def set_multilingualDescription(opts = {})
|
44
|
+
private
|
45
|
+
|
46
|
+
def extend_model_methods
|
47
47
|
if self.respond_to?(:multilingualDescription)
|
48
|
-
|
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"
|
48
|
+
extend MultiLingualDescription
|
57
49
|
end
|
58
|
-
end
|
59
|
-
|
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
50
|
if self.respond_to?(:multilingualTitle)
|
65
|
-
|
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"
|
51
|
+
extend MultiLingualTitle
|
74
52
|
end
|
75
53
|
end
|
76
54
|
|
77
|
-
private
|
78
|
-
|
79
55
|
def on_before_create
|
80
56
|
self.attributes.delete_if { |k, v| v.nil? || v == "" }
|
81
57
|
self.attributes = self.attributes.deep_symbolize_keys
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Dina
|
2
|
+
module MultiLingualDescription
|
3
|
+
|
4
|
+
# Adds or updates a multilingualDescription with a language key
|
5
|
+
#
|
6
|
+
# @param opts [Hash] the description expessed as { en: "My description" }
|
7
|
+
def set_multilingualDescription(opts = {})
|
8
|
+
if self.multilingualDescription.nil?
|
9
|
+
self.multilingualDescription = opts
|
10
|
+
else
|
11
|
+
descriptions = multilingualDescription["descriptions"]
|
12
|
+
descriptions.delete_if{|o| o["lang"] == opts.keys[0].to_s}
|
13
|
+
descriptions << { "lang" => opts.keys[0].to_s, "desc" => opts[opts.keys[0]] }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Dina
|
2
|
+
module MultiLingualTitle
|
3
|
+
|
4
|
+
# Adds or updates a multilingualTitle with a language key
|
5
|
+
#
|
6
|
+
# @param opts [Hash] the title expessed as { en: "My title" }
|
7
|
+
def set_multilingualTitle(opts = {})
|
8
|
+
if self.multilingualTitle.nil?
|
9
|
+
self.multilingualTitle = opts
|
10
|
+
else
|
11
|
+
titles = multilingualTitle["titles"]
|
12
|
+
titles.delete_if{|o| o["lang"] == opts.keys[0].to_s}
|
13
|
+
titles << { "lang" => opts.keys[0].to_s, "title" => opts[opts.keys[0]] }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/dina/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David P. Shorthouse
|
@@ -199,6 +199,8 @@ files:
|
|
199
199
|
- lib/dina/search/search_mapping.rb
|
200
200
|
- lib/dina/utils/identifier.rb
|
201
201
|
- lib/dina/utils/identifier_type.rb
|
202
|
+
- lib/dina/utils/multi_lingual_description.rb
|
203
|
+
- lib/dina/utils/multi_lingual_title.rb
|
202
204
|
- lib/dina/version.rb
|
203
205
|
homepage: https://github.com/dshorthouse/dina
|
204
206
|
licenses:
|