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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 620e59a87be3c3adb55fba2d7d4084a12fbb12a78427ca53de33426ae8510110
4
- data.tar.gz: 6c2c5daff310c35f43b165156fc06944d44e4a74db84da12af055fb4d0be401d
3
+ metadata.gz: 8ccd7e97e13338d74abe532c9682da8c190428a6a49e9f185ab8b8ced6ac31ac
4
+ data.tar.gz: 65fbba40026990fd8cfaa90803e8c909dc3431eea4585800093d9c433801bb25
5
5
  SHA512:
6
- metadata.gz: 3b5913b6fe291bbcb26b4c5bf298bf4f6307077e006442952ad1937833952074728352cc1f0e1e01a6abfa8f5197b06161ddf1ef674dc29a4012761f46ed231a
7
- data.tar.gz: dea42bb62339358120b3d890edd22727c81058e30e6b9b3c7443d90e515e10942a12533bc94e52b5d8a6a8578d1ba67e70e6c4e1366672c828a789c1bace37e0
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
- # 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
+ private
45
+
46
+ def extend_model_methods
47
47
  if self.respond_to?(: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"
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
- 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"
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
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- PATCH = 4
6
+ PATCH = 5
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
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.0
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: