glia-errors 0.15.1 → 0.15.2

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: d3c4715a02f44b52b0031084f190a6a589130cf17634c44e762f5340285a1b79
4
- data.tar.gz: d208384077179f6eb0a5d80978e156e3d063d2a6410e42c9daabd8134e3b8065
3
+ metadata.gz: 48f6a6310b82d72e3d0a635c38839b494fc61dc48157ad1373ae02f2c6615d50
4
+ data.tar.gz: 10b23d6c1b11dfb98e238a8bb61a52dbec239aaafa632b030e3f0f766428d46c
5
5
  SHA512:
6
- metadata.gz: c3d5a3826b9244860ff36f1c68d42ff198bb83b96e5f0e72e5a2096ad7148e8680ebf98437885894ecfff01beeda5f04246a2b5c371a1904b8490f6d80cb2d79
7
- data.tar.gz: 93c6ec3cfad1625c86b76e5a1472e738b8baf20980dcb1a76a627c8e6bda132e1507b94832e8a8c60cea90d3cdf29bb1d223761acf3c36bc4871e8567d625c19
6
+ metadata.gz: 1d4fdd3e92aa7813263b8bdc127f98de09039d0ad6fb0de0115e623ce47025b341ad7717ce94f18b4e03baea4d785dc3214f18cb24221b1c4dc6aad884c1bb54
7
+ data.tar.gz: f340b151ad28ea9c896f97dfc9139672ce145fd2a031b8c809d6920f616d561e4bb88574ccabeb139f33e27ad661ea88929c3c9533a79306ffc0bff26fc31a99
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glia-errors (0.15.1)
4
+ glia-errors (0.15.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/glia-errors.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'glia-errors'
8
- spec.version = '0.15.1'
8
+ spec.version = '0.15.2'
9
9
  spec.authors = ['Glia TechMovers']
10
10
  spec.email = ['techmovers@glia.com']
11
11
 
@@ -170,7 +170,7 @@ module Glia
170
170
 
171
171
  default_message =
172
172
  "cannot be modified/deleted because it is associated to one or more #{
173
- Naming.humanize(associated_resource)
173
+ Naming.humanize(associated_resource, lowercase: true)
174
174
  }(s)"
175
175
  super(
176
176
  type: REMAINING_ASSOCIATION_ERROR,
@@ -248,6 +248,23 @@ module Glia
248
248
  end
249
249
  end
250
250
 
251
+ class ChangingFieldNotAllowedError < Error
252
+ def initialize(resource:, field:, message: nil)
253
+ Naming.assert_snake_case(resource)
254
+ Naming.assert_snake_case(field)
255
+
256
+ default_message =
257
+ "Once value of `#{field}` is set for the #{Naming.humanize(resource, lowercase: true)}, it cannot be changed"
258
+
259
+ super(
260
+ type: CHANGING_FIELD_NOT_ALLOWED_ERROR,
261
+ ref: create_ref(CHANGING_FIELD_NOT_ALLOWED_ERROR),
262
+ message: message || default_message,
263
+ error_details: { resource: resource, field: field }
264
+ )
265
+ end
266
+ end
267
+
251
268
  class AuthorizationError < Error
252
269
  def initialize(message: nil)
253
270
  super(
@@ -19,6 +19,7 @@ module Glia
19
19
  RESOURCE_LOCKED = 'resource_locked'
20
20
  RESOURCE_ALREADY_EXISTS_ERROR = 'resource_already_exists_error'
21
21
  INVALID_RESOURCE_STATE_ERROR = 'invalid_resource_state_error'
22
+ CHANGING_FIELD_NOT_ALLOWED_ERROR = 'changing_field_not_allowed_error'
22
23
  AUTHORIZATION_ERROR = 'authorization_error'
23
24
  RECIPIENT_OPTED_OUT_ERROR = 'recipient_opted_out_error'
24
25
  ROUTE_NOT_FOUND_ERROR = 'route_not_found_error'
@@ -7,10 +7,10 @@ module Glia
7
7
  # Converts from camel_case to more human readable value
8
8
  # first_name => "First name"
9
9
  # site_id => "Site ID"
10
- def self.humanize(value)
10
+ def self.humanize(value, lowercase: false)
11
11
  result = value.to_s.split('_').map { |word| upcase_if_abbreviation(word) }.join(' ')
12
12
 
13
- upcase_first(result)
13
+ lowercase ? result : upcase_first(result)
14
14
  end
15
15
 
16
16
  ABBREVIATIONS = %w[id uuid saml sip sms mms uri url].freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glia-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: