trailblazer-developer 0.0.26 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- module Trailblazer
2
- module Developer
3
- module Trace
4
-
5
- # This module does the inspection of given `ctx` with deep traversal.
6
- # It only gets called when focusing is going on (i.e. focus_on API).
7
- module Inspector
8
- module_function
9
-
10
- def call(value, default_inspector: method(:default_inspector), **)
11
- return hash_inspector(value, default_inspector: default_inspector) if value.is_a?(Hash)
12
- return array_inspector(value, default_inspector: default_inspector) if value.is_a?(Array)
13
-
14
- default_inspector.(value)
15
- end
16
-
17
- def hash_inspector(value, default_inspector:)
18
- Hash[
19
- value.collect do |key, nested_value|
20
- [key, call(nested_value, default_inspector: default_inspector)]
21
- end
22
- ]
23
- end
24
-
25
- def array_inspector(value, default_inspector:)
26
- value.collect do |nested_value|
27
- call(nested_value, default_inspector: default_inspector)
28
- end
29
- end
30
-
31
- # To avoid additional query that AR::Relation#inspect makes,
32
- # we're calling AR::Relation#to_sql to get plain SQL string instead.
33
- def activerecord_relation_inspector(value)
34
- { query: value.to_sql }
35
- end
36
-
37
- def default_inspector(value)
38
- if defined?(ActiveRecord) && value.is_a?(ActiveRecord::Relation)
39
- return activerecord_relation_inspector(value)
40
- end
41
-
42
- value.inspect
43
- end
44
- end
45
-
46
- end
47
- end
48
- end