safer_initialize 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -1
- data/lib/safer_initialize.rb +11 -0
- data/lib/safer_initialize/active_record/extensions.rb +3 -1
- data/lib/safer_initialize/configuration.rb +9 -0
- data/lib/safer_initialize/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31eb1c05500e2d20207203e3d4d65a29507920d6f0da6b0cadaef0d87df81b12
|
4
|
+
data.tar.gz: 9d8f0360e41cb13a56314c79c3bb64e46ba892ffcc40351d1ec241ab96f53b0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1cb3bbc1654debbf28f5e336bd46bc7f03ad9ed3e65d1e651f41e3a83bff1591a3e5e4418f41027cc557e78796e299c40537a590cbb5ebc34b762e14df0a8c0
|
7
|
+
data.tar.gz: 5dd462b38e4b9058de7eccf5853aa788133d2374282f3af2297b02cdacef1b20e22a77600f7546e0cb6ca4c9785f17d92e0ffea4c171dbd46710c31e30a38482
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,6 +24,10 @@ In `config/initializers/safer_initialize.rb`:
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
SaferInitialize::Globals.attribute :tenant
|
27
|
+
|
28
|
+
SaferInitialize.configure do |config|
|
29
|
+
config.error_handle = -> (e) { Rails.env.production? ? Bugsnag.notify(e) : raise e } # default: -> (e) { raise e }
|
30
|
+
end
|
27
31
|
```
|
28
32
|
|
29
33
|
In `app/models/project.rb`:
|
@@ -70,7 +74,7 @@ In `app/views/projects/index.html.haml`:
|
|
70
74
|
= project.name
|
71
75
|
|
72
76
|
- SaferInitialize.with_safe do
|
73
|
-
- current_tenant.
|
77
|
+
- current_tenant.projects.each do |project|
|
74
78
|
= project.name
|
75
79
|
```
|
76
80
|
|
data/lib/safer_initialize.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
require 'safer_initialize/version'
|
2
2
|
require 'safer_initialize/globals'
|
3
|
+
require 'safer_initialize/configuration'
|
3
4
|
require 'safer_initialize/railtie'
|
4
5
|
|
5
6
|
module SaferInitialize
|
6
7
|
class Error < StandardError; end
|
7
8
|
|
9
|
+
class << self
|
10
|
+
def configure
|
11
|
+
yield(configuration)
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
module_function
|
9
20
|
|
10
21
|
def with_safe(&block)
|
@@ -8,7 +8,9 @@ module SaferInitialize
|
|
8
8
|
after_initialize do |object|
|
9
9
|
unless SaferInitialize::Globals.safe?
|
10
10
|
result = filter ? object.send(filter) : object.instance_exec(object, &block)
|
11
|
-
|
11
|
+
unless result
|
12
|
+
SaferInitialize.configuration.error_handle.call(SaferInitialize::Error.new(message))
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safer_initialize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- bin/setup
|
45
45
|
- lib/safer_initialize.rb
|
46
46
|
- lib/safer_initialize/active_record/extensions.rb
|
47
|
+
- lib/safer_initialize/configuration.rb
|
47
48
|
- lib/safer_initialize/globals.rb
|
48
49
|
- lib/safer_initialize/railtie.rb
|
49
50
|
- lib/safer_initialize/version.rb
|