eac_rails_utils 0.17.2 → 0.18.0

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: efe1c5f0500cc98440fb31e38b2ecdcf3959d5d415016ac4ad622d1a309a4695
4
- data.tar.gz: 23e56f4eae5a1126c3136971cb84d74755aeed649f18eafc6dc10dc6118f1327
3
+ metadata.gz: e69ab406dd1dd999da6a2fdefa92e15ad6c1a2faeb14f0474fa7fd20938a71ef
4
+ data.tar.gz: f91fdd425c80747f432acbcdd4ed80c399eed2e80f3d1e862699dbb0839d9077
5
5
  SHA512:
6
- metadata.gz: 63ec98f3e567a68e2aa5f82d09e9fa8283861ea7d2801175f2969b13abaa126511c73a22ed7d35c5862f4a9a4c67f4553049aef96a775a4fcfae8af6e214ea13
7
- data.tar.gz: f626434211fb0d7743fc22e6deb20fe0edc216f7ec6d425cf5514e88c1652e8b37031c4f5ebf202a41e277ca22163e7dc8012bc34c865be7d05c62d87542a286
6
+ metadata.gz: 0f772b792fb6684dfff2e450286e5f014d04e4b9c45630a8cc7d3486c9a70cb895381ba4480e973a4b2cdc4cde5a29bfa94392c8e2efc9e141a08e2ce0e126d4
7
+ data.tar.gz: 2a5cc246cb003b694e2701bb70409cc7df7e2e69fc80d093a47912dbed5d50c2e1cdab740e4e9d36f29469cc84fd8bc83a50fd15f66cbda35b4ecd328093139a
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsUtils
4
+ class ImmutableValidator < ActiveModel::EachValidator
5
+ DEFAULT_MESSAGE = 'cannot be changed'
6
+
7
+ def validate_each(record, attribute, _value)
8
+ return if record.new_record?
9
+ return unless record.send("#{attribute}_changed?")
10
+
11
+ record.errors[attribute] << (options[:message] || DEFAULT_MESSAGE)
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.17.2'
4
+ VERSION = '0.18.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.2
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -203,6 +203,7 @@ files:
203
203
  - app/helpers/eac_rails_utils/menus_helper/gui_builder.rb
204
204
  - app/helpers/eac_rails_utils/open_graph_protocol_helper.rb
205
205
  - app/validators/eac_rails_utils/cpf_validator.rb
206
+ - app/validators/eac_rails_utils/immutable_validator.rb
206
207
  - app/validators/eac_rails_utils/no_presence_validator.rb
207
208
  - app/validators/eac_rails_utils/yaml_validator.rb
208
209
  - config/initializers/assets.rb