solidus_core 2.11.7 → 2.11.8

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: f4d85b2e48b45c5f20a8de9e1152813de4731e283946bb69c1bef2c01b8b9455
4
- data.tar.gz: 78b9982563a8722a9892313dc8c3a4f2631d291679cad631c482c13b25279090
3
+ metadata.gz: e0d36b03697769f4d9449dfeac2da6004e9d06b7d1575489abbbecf5497dfae1
4
+ data.tar.gz: a0de4d86e474402ac44765317ab8ffb2967dbb4de6675491616af185e17fb3dd
5
5
  SHA512:
6
- metadata.gz: ae52ba5c560040d3e6096d129dafc377b59de4ac7a536728f28c5099846d727e511ae2604f72f47473117cdc25e6b69e3aa690aeecc3df9d57a66b592cd73b80
7
- data.tar.gz: 2662be65dd3122d1f35bbd272b2b341ec4a54f123bde9acadb5145b726164a8bed4b4956d62c9577527ce9f130c040ffff0958bd576525c29eb7690d7bbf8ea6
6
+ metadata.gz: 6f1a2577af4ea0108060bb3e9d81e81fa7114813b6ce5b1d925f53378da6b2f9c41b5e22d67d65389d2ee4e3d57719c79855fa4bbbb820f0cac68b63afeb313a
7
+ data.tar.gz: f4bf3efd9563905b2eca58c6df0b95c9c1591b0a46c07cbc4bfaaed0000cd691f2e9333dc7f860c78a0a450c38f38f2a74d1b8ab63f15e188ac46de5d7080520
@@ -1,28 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
4
+
3
5
  class Spree::Base < ActiveRecord::Base
4
- include Spree::Preferences::Preferable
5
6
  include Spree::Core::Permalinks
6
7
  include Spree::RansackableAttributes
7
8
 
8
- def preferences
9
- read_attribute(:preferences) || self.class.preferences_coder_class.new
9
+ def self.preference(*args)
10
+ Spree::Deprecation.warn <<~WARN
11
+ #{name} has a `preferences` column, but does not explicitly (de)serialize this column.
12
+ In order to make #{name} work with future versions of Solidus (and Rails), please add the
13
+ following line to your class:
14
+ ```
15
+ class #{name}
16
+ include Spree::Preferences::Persistable
17
+ ...
18
+ end
19
+ ```
20
+ WARN
21
+ include Spree::Preferences::Persistable
22
+ preference(*args)
10
23
  end
11
24
 
12
- def initialize_preference_defaults
13
- if has_attribute?(:preferences)
14
- self.preferences = default_preferences.merge(preferences)
15
- end
16
- end
25
+ def preferences
26
+ value = read_attribute(:preferences)
27
+ if !value.is_a?(Hash)
28
+ Spree::Deprecation.warn <<~WARN
29
+ #{self.class.name} has a `preferences` column, but does not explicitly (de)serialize this column.
30
+ In order to make #{self.class.name} work with future versions of Solidus (and Rails), please add the
31
+ following lines to your class:
32
+ ```
33
+ class #{self.class.name}
34
+ include Spree::Preferences::Persistable
35
+ ...
36
+ end
37
+ ```
38
+ WARN
39
+ self.class.include Spree::Preferences::Persistable
17
40
 
18
- # Only run preference initialization on models which requires it. Improves
19
- # performance of record initialization slightly.
20
- def self.preference(*args)
21
- # after_initialize can be called multiple times with the same symbol, it
22
- # will only be called once on initialization.
23
- serialize :preferences, preferences_coder_class
24
- after_initialize :initialize_preference_defaults
25
- super
41
+ ActiveRecord::Type::Serialized.new(
42
+ ActiveRecord::Type::Text.new,
43
+ ActiveRecord::Coders::YAMLColumn.new(:preferences, Hash)
44
+ ).deserialize(value)
45
+ else
46
+ value
47
+ end
26
48
  end
27
49
 
28
50
  if Kaminari.config.page_method_name != :page
@@ -35,10 +57,6 @@ class Spree::Base < ActiveRecord::Base
35
57
  end
36
58
  end
37
59
 
38
- def self.preferences_coder_class
39
- Hash
40
- end
41
-
42
60
  self.abstract_class = true
43
61
 
44
62
  # Provides a scope that should be included any time products
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
4
+
3
5
  module Spree
4
6
  class Calculator < Spree::Base
7
+ include Spree::Preferences::Persistable
8
+
5
9
  belongs_to :calculable, polymorphic: true, optional: true
6
10
 
7
11
  # This method calls a compute_<computable> method. must be overriden in concrete calculator.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
3
4
  require 'spree/preferences/statically_configurable'
4
5
 
5
6
  module Spree
@@ -11,6 +12,8 @@ module Spree
11
12
  # This class is not meant to be instantiated. Please create instances of concrete payment methods.
12
13
  #
13
14
  class PaymentMethod < Spree::Base
15
+ include Spree::Preferences::Persistable
16
+
14
17
  preference :server, :string, default: 'test'
15
18
  preference :test_mode, :boolean, default: true
16
19
 
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
4
+
3
5
  module Spree
4
6
  # Base class for all types of promotion action.
5
7
  #
6
8
  # PromotionActions perform the necessary tasks when a promotion is activated
7
9
  # by an event and determined to be eligible.
8
10
  class PromotionAction < Spree::Base
11
+ include Spree::Preferences::Persistable
9
12
  include Spree::SoftDeletable
10
13
 
11
14
  belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_actions, optional: true
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'spree/preferences/persistable'
4
+
3
5
  module Spree
4
6
  # Base class for all promotion rules
5
7
  class PromotionRule < Spree::Base
8
+ include Spree::Preferences::Persistable
9
+
6
10
  belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_rules, optional: true
7
11
 
8
12
  scope :of_type, ->(type) { where(type: type) }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "2.11.7"
4
+ VERSION = "2.11.8"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Preferences
5
+ module Persistable
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ include Spree::Preferences::Preferable
10
+ serialize :preferences, Hash
11
+ after_initialize :initialize_preference_defaults
12
+ end
13
+
14
+ private
15
+
16
+ def initialize_preference_defaults
17
+ if has_attribute?(:preferences)
18
+ self.preferences = default_preferences.merge(preferences)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.7
4
+ version: 2.11.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -829,6 +829,7 @@ files:
829
829
  - lib/spree/permission_sets/user_management.rb
830
830
  - lib/spree/permitted_attributes.rb
831
831
  - lib/spree/preferences/configuration.rb
832
+ - lib/spree/preferences/persistable.rb
832
833
  - lib/spree/preferences/preferable.rb
833
834
  - lib/spree/preferences/preferable_class_methods.rb
834
835
  - lib/spree/preferences/scoped_store.rb