wallaby-core 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wallaby/classifier.rb +8 -4
- data/lib/wallaby/configuration.rb +0 -1
- data/lib/wallaby/core/version.rb +1 -1
- data/lib/wallaby/map.rb +8 -0
- data/lib/wallaby/preloader.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b4a388789a1a5aa912f7c4fed3b70fd532976c9b6fc2ae9261a409b523ff33
|
4
|
+
data.tar.gz: 7012ee8417e1f08269ec5591218caf5dc46f21ea02d97a0cfbe8eab80f1e3211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cffdaa2781b5ae95be81f28f297ae005905f0a003a40df321f6b0109a287d3098513194cea03e0747b92eaf25405b72890663f53c9f913042f3501a3476966d
|
7
|
+
data.tar.gz: b9992869729df06ce388e42d8bfdd0cf14ef3b7da487d04195038c1154f496d4ae44c013376710e28664c28bb561c424b97aa252ad23efe943d9597451376612
|
data/lib/wallaby/classifier.rb
CHANGED
@@ -23,14 +23,18 @@ module Wallaby
|
|
23
23
|
# blank string will lead to NameError `wrong constant name`
|
24
24
|
return if name.blank?
|
25
25
|
|
26
|
+
# [Performance] Caching the result for uninitialized constant
|
27
|
+
return (yield(name) if block_given?) if raising && Map.class_name_error_map[name] == :uninitialized
|
28
|
+
|
26
29
|
# NOTE: DO NOT try to use `const_defined?` and `const_get` EVER.
|
27
30
|
# Rails does all the class loading magics using `constantize`
|
28
31
|
name.constantize
|
29
32
|
rescue NameError => e
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
if raising
|
34
|
+
Map.class_name_error_map[name] ||=
|
35
|
+
e.message.start_with?('uninitialized constant') ? :uninitialized : :name_error
|
36
|
+
raise e if Map.class_name_error_map[name] == :name_error
|
37
|
+
end
|
34
38
|
|
35
39
|
# block to handle this missing constant, e.g. use a default class or log useful instruction
|
36
40
|
yield(name) if block_given?
|
@@ -104,7 +104,6 @@ module Wallaby
|
|
104
104
|
Deprecator.alert 'config.models.presence', from: '0.3.0', alternative: <<~INSTRUCTION
|
105
105
|
Please use controller_class.models instead.
|
106
106
|
INSTRUCTION
|
107
|
-
@models ||= Models.new
|
108
107
|
end
|
109
108
|
|
110
109
|
# To globally configure the models that Wallaby should handle.
|
data/lib/wallaby/core/version.rb
CHANGED
data/lib/wallaby/map.rb
CHANGED
@@ -102,6 +102,14 @@ module Wallaby
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
class << self
|
106
|
+
# @!attribute [r] class_name_error_map
|
107
|
+
# Cache the class name error
|
108
|
+
def class_name_error_map
|
109
|
+
@class_name_error_map ||= {}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
105
113
|
class << self
|
106
114
|
# Reset all the instance variables to nil
|
107
115
|
def clear
|
data/lib/wallaby/preloader.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wallaby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tianwen Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|