sbf-dm-noisy-failures 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/data_mapper/noisy_failures/version.rb +5 -0
- data/lib/data_mapper/noisy_failures.rb +46 -0
- data/lib/dm-noisy-failures.rb +1 -0
- data/lib/dm_noisy_failures.rb +2 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b3b3d9d519047b34b4dfff0b8f7c7e17d1d0b82e7a6d7c66ce08e79fee0e335d
|
4
|
+
data.tar.gz: 54f1344dc6b5a82e8db65b6d31f0c400f453cd12fc9c8d6cf34af00e632f52a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0a1e25166890e0a0dd9dcf4807ff08735b5df7263c12e739f0d015d66cbced83de60bc2470701397185d2567515cc3abb69a203d95dd5e1e391306a20b4ae57
|
7
|
+
data.tar.gz: deee9f2f8f940cae5765b6773b84b7a912171a2b6090531897fff76e7025bcede8a230f89fb269ad7b8d3dcda6e944653a9d0710e9b491ec6175623a2e6b4674
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module DataMapper
|
2
|
+
module Resource
|
3
|
+
alias_method :save?, :save
|
4
|
+
alias_method :destroy?, :destroy
|
5
|
+
|
6
|
+
def save
|
7
|
+
return true if save? || errors.empty?
|
8
|
+
|
9
|
+
error_message = errors.map { |e| "#{self.class}: #{e.join(', ')}" }.join('; ')
|
10
|
+
raise SaveFailureError.new(error_message, self)
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
return true if destroy?
|
15
|
+
|
16
|
+
error_message = "#{self.class}: Unable to destroy, probably due to associated records."
|
17
|
+
raise SaveFailureError.new(error_message, self)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update?(*args)
|
21
|
+
update(*args)
|
22
|
+
true
|
23
|
+
rescue
|
24
|
+
# This seems like the cleanest way of doing this. #update calls #save internally, so we can't
|
25
|
+
# use alias_method because then #update? would call #save, which would raise an exception now
|
26
|
+
# that we've done our monkey-patching.
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
@@original_included_method = begin
|
31
|
+
method(:included)
|
32
|
+
rescue
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.included(base)
|
37
|
+
@@original_included_method&.call(base)
|
38
|
+
|
39
|
+
def base.create?(*args)
|
40
|
+
create(*args)
|
41
|
+
rescue
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'dm_noisy_failures'
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sbf-dm-noisy-failures
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Tao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: data_mapper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sbf-dm-core
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.0.beta
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.0.beta
|
41
|
+
description: This library replaces the default behavior of DataMapper by raising exceptions
|
42
|
+
with descriptive error messages whenever DB operations are not successfully completed.
|
43
|
+
email:
|
44
|
+
- daniel.tao@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- lib/data_mapper/noisy_failures.rb
|
50
|
+
- lib/data_mapper/noisy_failures/version.rb
|
51
|
+
- lib/dm-noisy-failures.rb
|
52
|
+
- lib/dm_noisy_failures.rb
|
53
|
+
homepage: https://github.com/dtao/dm-noisy-failures
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.7.8
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubygems_version: 3.4.10
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Noisy (and descriptive) failures for DataMapper
|
76
|
+
test_files: []
|