servitium 1.3.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73577669d7e1165bb7d7de0e70c4518170dd635633b85c3e71679afebc54a984
4
- data.tar.gz: 3ffaf736b2fd00147d2af9314be5f5b9406d3a44df34947f7125f6ed10c3f383
3
+ metadata.gz: 8a0ef3ad8b27e23da12fb7e38523b6791067182326c4eb687ff783c04590a48b
4
+ data.tar.gz: 7db9f17e28035c835626d7a95b53566fcc970cee967753666ad6651ca5553005
5
5
  SHA512:
6
- metadata.gz: cd2a964e717be6dff505e001f5724908cf5eb153b06db3bdd15c5860946841203b90a788dbc5170b89a8e9a3b06a2f074e729890a85e80315e50c447cf0f37ed
7
- data.tar.gz: d038dd4666e69f6f50273b8f9b67377d6e41e643369b6ab34d6820350b709dedb924f3919720416bec958b3cbf93a29d74a691c57d45358ddd459573a3b0e9b4
6
+ metadata.gz: 21d99ac12c2a0b21d15c3344c1f25ccf01151a10516794485d7343e9d8b9940e7b555fc5fcd29c563c937d3810cd22cd747f551aca54d78db112a2dbc48c625e
7
+ data.tar.gz: d112f878db7d4f82e806d34805a80e5cd5cd28388d4e7a728f0c2b8d4e7af3cfb02fdbcf8b2a533977bc875d230b984ef1ef8151a4c904141c0656ccf3f8c4b7
@@ -56,8 +56,31 @@ module Servitium
56
56
  def _destroy
57
57
  end
58
58
 
59
+ # Rails 8 ActiveModel::Dirty expects attribute values to respond to +changed_in_place?+
60
+ # (e.g. when using NumericalityValidator). ActiveAttr stores raw values, so we ensure
61
+ # every value in @attributes responds to it. write_attribute covers normal writes;
62
+ # apply_defaults covers defaults (ActiveAttr writes those directly to @attributes).
63
+ def write_attribute(name, value)
64
+ ensure_changed_in_place!(value)
65
+ super
66
+ end
67
+
68
+ def apply_defaults(defaults = attribute_defaults)
69
+ super
70
+ (@attributes || {}).each_value { |value| ensure_changed_in_place!(value) }
71
+ end
72
+
59
73
  private
60
74
 
75
+ def ensure_changed_in_place!(value)
76
+ return if value.nil? || value.respond_to?(:changed_in_place?)
77
+
78
+ value.define_singleton_method(:changed_in_place?) { false }
79
+ rescue TypeError
80
+ # Integer, Float, Symbol, true, false, nil etc. can't get singleton methods;
81
+ # they use the class-level method from rails8_value_dirty_compat.
82
+ end
83
+
61
84
  def validate_subcontexts
62
85
  @subcontexts.each do |key, value|
63
86
  errors.add(key, "invalid") unless [*value].find_all { |v| v.respond_to?(:invalid?) && v.invalid? }.empty?
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Rails 8 compatibility: ActiveModel::Dirty expects attribute values to respond to
4
+ # +changed_in_place?+. Value types (Integer, Float, Symbol, etc.) can't get
5
+ # singleton methods in Ruby, so we add the method at the class level here.
6
+ # Servitium/ActiveAttr context attributes use these types; without this, validations
7
+ # (e.g. NumericalityValidator) raise NoMethodError.
8
+
9
+ require "bigdecimal"
10
+ require "date"
11
+
12
+ [
13
+ String, Integer, Float, BigDecimal,
14
+ TrueClass, FalseClass, NilClass, Symbol,
15
+ Date, Time, Array, Hash
16
+ ].each do |klass|
17
+ next if klass.method_defined?(:changed_in_place?)
18
+
19
+ klass.define_method(:changed_in_place?) { false }
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servitium
4
- VERSION = "1.3.3"
4
+ VERSION = "1.3.5"
5
5
  end
data/lib/servitium.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "active_model"
4
4
  require "active_attr"
5
5
  require "active_support"
6
+ require "servitium/rails8_value_dirty_compat"
6
7
  require "action_controller"
7
8
  require "active_job"
8
9
  require "sidekiq"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-21 00:00:00.000000000 Z
11
+ date: 2026-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -281,6 +281,7 @@ files:
281
281
  - lib/servitium/i18n.rb
282
282
  - lib/servitium/rails.rb
283
283
  - lib/servitium/rails/railtie.rb
284
+ - lib/servitium/rails8_value_dirty_compat.rb
284
285
  - lib/servitium/scoped_attributes.rb
285
286
  - lib/servitium/service.rb
286
287
  - lib/servitium/service_active_job.rb