alchemy_cms 6.0.4 → 6.0.5

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: e9bfd92678d3b4ae867e8c3938a0277d7698fb6fbcfb80a0210f0c4371990486
4
- data.tar.gz: ce854781846eadaecdbe717ab435a38d357cda54863707b2c62a61cf4730884b
3
+ metadata.gz: c5eb21e30df422e1b214dd34d5d6166d8aaf195d393590efdf1e6a16a1247910
4
+ data.tar.gz: aa579d8246cfc7952a2f2491c86a78e272733eb7c21d993d4302201ee2b1a3f3
5
5
  SHA512:
6
- metadata.gz: 51391e56da530c900189d8c16b756d9084fac351cfc50ebc2ee9b7181d7148c826daf39bdd284100261aa6e4ae5c1a4f28eb266c1a31d9fd1ad31f21e2cda398
7
- data.tar.gz: 244eb43ca4783a572c5885c69571264a50d4154a5ccfc8b5af806f1343497cc38a8157a1b8c039262d60ea8f4cd6a3a19777943ca9b1c0654a6cd473d3f9f025
6
+ metadata.gz: 4b92efbc92492ccbc49ff95249672d5083499898d6ce70644b68a44fdc49720a716986c138211c308c1e3cf3a7b614db6d04a9463399c81c8167b31622aa1f5c
7
+ data.tar.gz: 4d297aea832eeea8b51183b234bcad0cacc168283e07f1d83ca180e1a59fb02601756869e74c3348f10b14308a62e660d6dd2b0a04251da51b4c574435e4518a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 6.0.5 (2022-05-11)
2
+
3
+ - Extract element ingredient migrator [#2337](https://github.com/AlchemyCMS/alchemy_cms/pull/2337) ([tvdeyen](https://github.com/tvdeyen))
4
+
1
5
  ## 6.0.4 (2022-05-06)
2
6
 
3
7
  - Add support for Rails' recycable cache keys [#2334](https://github.com/AlchemyCMS/alchemy_cms/pull/2334) ([tvdeyen](https://github.com/tvdeyen))
@@ -24,31 +24,8 @@ module Alchemy::Upgrader::Tasks
24
24
  if elements.any?
25
25
  puts "-- Creating ingredients for #{elements.count} #{element_definition[:name]}(s)"
26
26
  elements.each do |element|
27
- Alchemy::Element.transaction do
28
- element_definition[:ingredients].each do |ingredient_definition|
29
- content = element.content_by_name(ingredient_definition[:role])
30
- next unless content
31
-
32
- essence = content.essence
33
- ingredient = element.ingredients.build(
34
- role: ingredient_definition[:role],
35
- type: Alchemy::Ingredient.normalize_type(ingredient_definition[:type]),
36
- )
37
- belongs_to_associations = essence.class.reflect_on_all_associations(:belongs_to)
38
- if belongs_to_associations.any?
39
- ingredient.related_object = essence.public_send(belongs_to_associations.first.name)
40
- else
41
- ingredient.value = content.ingredient
42
- end
43
- data = ingredient.class.stored_attributes.fetch(:data, []).each_with_object({}) do |attr, d|
44
- d[attr] = essence.public_send(attr)
45
- end
46
- ingredient.data = data
47
- print "."
48
- ingredient.save!
49
- content.destroy!
50
- end
51
- end
27
+ MigrateElementIngredients.call(element)
28
+ print "."
52
29
  end
53
30
  puts "\n"
54
31
  else
@@ -58,5 +35,38 @@ module Alchemy::Upgrader::Tasks
58
35
  end
59
36
  end
60
37
  end
38
+
39
+ class MigrateElementIngredients
40
+ def self.call(element)
41
+ Alchemy::Element.transaction do
42
+ element.definition[:ingredients].each do |ingredient_definition|
43
+ ingredient = element.ingredients.build(
44
+ role: ingredient_definition[:role],
45
+ type: Alchemy::Ingredient.normalize_type(ingredient_definition[:type]),
46
+ )
47
+
48
+ content = element.content_by_name(ingredient_definition[:role])
49
+ if content
50
+ essence = content.essence
51
+ if essence
52
+ belongs_to_associations = essence.class.reflect_on_all_associations(:belongs_to)
53
+ if belongs_to_associations.any?
54
+ ingredient.related_object = essence.public_send(belongs_to_associations.first.name)
55
+ else
56
+ ingredient.value = content.ingredient
57
+ end
58
+ data = ingredient.class.stored_attributes.fetch(:data, []).each_with_object({}) do |attr, d|
59
+ d[attr] = essence.public_send(attr)
60
+ end
61
+ ingredient.data = data
62
+ end
63
+ content.destroy!
64
+ end
65
+
66
+ ingredient.save!
67
+ end
68
+ end
69
+ end
70
+ end
61
71
  end
62
72
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "6.0.4"
4
+ VERSION = "6.0.5"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "6.0.4",
3
+ "version": "6.0.5",
4
4
  "description": "AlchemyCMS",
5
5
  "browser": "package/admin.js",
6
6
  "files": [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.4
4
+ version: 6.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2022-05-06 00:00:00.000000000 Z
16
+ date: 2022-05-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionmailer