infopark_fiona_connector 7.0.1.6.1.6.rc1 → 7.0.1.6.1.6.rc2

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: a2b76b71446af6398f3aaf4f81e328ac901695595c8f46ec767c2114a9782f28
4
- data.tar.gz: 461cf4e95303c46a64fef16bd4a8f2b6ee30359377adc4956b4c0d554f14a023
3
+ metadata.gz: 354adf51aab5a30ed1a7760f4543f8dfcbbb67e0390bf20c57f9f2da31e8c4c9
4
+ data.tar.gz: 3e9e8398ea686d96065f77c4565136364b2b36fe2a76ad83a832d50e60629717
5
5
  SHA512:
6
- metadata.gz: b3515ef24dd4e51fb8e4243af991208d2b58e1fb215cbdc0eced0df0b3f4e4284230b93d5c3c742d1670bf0e049d8d5a56061998767bb40a67cb0363fdaa9def
7
- data.tar.gz: a6113fbe1c6131056e798e5ad4e8467340ccc7a37872f45912a84c7114269341b36bc97fbcdaea9494506cb5ca9500bd6b310324b1a15e71d57c0670af8d6ff6
6
+ metadata.gz: 0fb8ab8a8ebb91a9c2f94569efd01da7dcff2495cb5a1958a81ecbea1869751b4ba3246f22b685d67852e4e24aac3639543ad8f0b87dcfa28c9516e1d3a08d01
7
+ data.tar.gz: 5cfebc09e5ce14e2a8bd287e1c026c92714ef880c5edd5baac100a9ef1f11d5b0aad32141efa2899b00483298d70577fbaad2d2fbeb45da07d7d1d2638126311
@@ -37,16 +37,6 @@ module RailsConnector
37
37
  true
38
38
  end
39
39
 
40
- def attribute_for_inspect(attr_name)
41
- value = read_attribute(attr_name)
42
-
43
- if value.is_a?(RailsConnector::LinkList)
44
- value.destination_objects.map(&:to_s)
45
- else
46
- super
47
- end
48
- end
49
-
50
40
  class << self
51
41
  # The prefix of the table name is determined by using the instance name followed by an underscore.
52
42
  # Set the instance_name in your environment to the CMS instance name (defaults to 'default').
@@ -0,0 +1,76 @@
1
+ # Patches for ActiveRecord::Core (see include in engine.rb)
2
+ module RailsConnector
3
+ module CoreExtensions
4
+ module ActiveRecord
5
+ module Core
6
+ # Reason for patch: activerecord/lib/active_record/core#inspect does not support RailsConnector::Linklist.
7
+ # We need to transform RailsConnector::Linklist to a string to prevent circular references.
8
+ # Rails 6.0 does not make use of `attribute_for_inspect`, therefore we need to patch `format_for_inspect` directly.
9
+ # `format_for_inspect` in > 6.1 uses two parameters
10
+ #
11
+ # Reason for change: activerecord/lib/active_record/core#inspect might change in future Rails versions.
12
+ if Rails::VERSION::MAJOR < 6
13
+ def attribute_for_inspect(attr_name)
14
+ value = read_attribute(attr_name)
15
+
16
+ if value.is_a?(RailsConnector::LinkList)
17
+ value.destination_objects.map(&:to_s)
18
+ else
19
+ super
20
+ end
21
+ end
22
+ elsif Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR.zero?
23
+ def format_for_inspect(value)
24
+ if value.is_a?(RailsConnector::LinkList)
25
+ value.destination_objects.map(&:to_s)
26
+ else
27
+ super
28
+ end
29
+ end
30
+ else
31
+ def attribute_for_inspect(attr_name)
32
+ attr_name = attr_name.to_s
33
+ attr_name = self.class.attribute_aliases[attr_name] || attr_name
34
+ value = _read_attribute(attr_name)
35
+ if value.present? && value.is_a?(RailsConnector::LinkList)
36
+ value.destination_objects.map(&:to_s)
37
+ else
38
+ super
39
+ end
40
+ end
41
+ end
42
+
43
+ # Reason for patch: activerecord/lib/active_record/core#pretty_print ends up in circular reference,
44
+ # as RailsConnector::Linklist was not handled. infopark_reactor/lib/reactor/attributes.rb#_read_attribute(attr_name) overwrites
45
+ # the method, which is called by activerecord/lib/active_record/core#pretty_print.
46
+ #
47
+ # Reason for change: activerecord/lib/active_record/core#pretty_print might change in future Rails versions.
48
+ # Check rails console output of an Obj with RailsConnector::Linklist attributes.
49
+ def pretty_print(pp)
50
+ return super if custom_inspect_method_defined?
51
+
52
+ pp.object_address_group(self) do
53
+ if defined?(@attributes) && @attributes
54
+ attr_names = self.class.attribute_names.select { |name| has_attribute?(name) }
55
+ pp.seplist(attr_names, proc { pp.text "," }) do |attr_name|
56
+ pp.breakable " "
57
+ pp.group(1) do
58
+ pp.text attr_name
59
+ pp.text ":"
60
+ pp.breakable
61
+ value = _read_attribute(attr_name)
62
+ value = value.destination_objects.map(&:to_s) if value.present? && value.is_a?(RailsConnector::LinkList)
63
+ value = inspection_filter.filter_param(attr_name, value) unless value.nil?
64
+ pp.pp value
65
+ end
66
+ end
67
+ else
68
+ pp.breakable " "
69
+ pp.text "not initialized"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1 +1,2 @@
1
1
  require "rails_connector/core_extensions/time"
2
+ require "rails_connector/core_extensions/active_record/core"
@@ -10,6 +10,14 @@ module ::RailsConnector
10
10
  # make sure our exceptions cause an adequate error page and http status code
11
11
  config.action_dispatch.rescue_responses["RailsConnector::ResourceNotFound"] = :not_found
12
12
 
13
+ initializer "Rails patches" do
14
+ config.to_prepare do
15
+ ActiveSupport.on_load(:active_record) do
16
+ include RailsConnector::CoreExtensions::ActiveRecord::Core
17
+ end
18
+ end
19
+ end
20
+
13
21
  initializer "rails_connector.add_fiona_time_type" do
14
22
  ActiveSupport.on_load(:active_record) do
15
23
  ActiveRecord::Type.register(:fiona_datetime, FionaDateTime)
@@ -70,6 +78,7 @@ module ::RailsConnector
70
78
  autoloader.ignore("#{config.root}/lib/version.rb")
71
79
  autoloader.ignore("#{config.root}/lib/rails_connector/core_extensions.rb")
72
80
  autoloader.ignore("#{config.root}/lib/rails_connector/core_extensions/time.rb")
81
+ autoloader.ignore("#{config.root}/lib/rails_connector/core_extensions/active_record/core.rb")
73
82
  autoloader.ignore("#{config.root}/lib/rails_connector/errors.rb")
74
83
  autoloader.ignore("#{config.root}/lib/rails_connector/fiona_date_time.rb")
75
84
  autoloader.ignore("#{config.root}/lib/rails_connector/rack_middlewares.rb")
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module RailsConnector
2
2
  module Version
3
3
  def self.get
4
- "7.0.1.6.1.6.rc1"
4
+ "7.0.1.6.1.6.rc2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_fiona_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1.6.1.6.rc1
4
+ version: 7.0.1.6.1.6.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -220,6 +220,7 @@ files:
220
220
  - lib/rails_connector/configuration.rb
221
221
  - lib/rails_connector/content.rb
222
222
  - lib/rails_connector/core_extensions.rb
223
+ - lib/rails_connector/core_extensions/active_record/core.rb
223
224
  - lib/rails_connector/core_extensions/time.rb
224
225
  - lib/rails_connector/date_attribute.rb
225
226
  - lib/rails_connector/default_search_request.rb