activerecord-quick_read 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activerecord/quick_read/lite_base.rb +16 -14
- data/lib/activerecord/quick_read/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d401b9ac50f22d00aeecc23fa0b526b6be514bd0ff16ef9b59de596e43b26ba
|
4
|
+
data.tar.gz: e62a73b6cd6295759857c0a1600bd012e552dcdf6594cb9512678296e627311c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994202293a9083b9bc13fb25707abea8cfd455eefa7804065a6ce2ebb80f42f258a4db8017825fec312dce6e999560f6c349c2edbdd1be264067c80ec8a082c7
|
7
|
+
data.tar.gz: 357fee568bb033ed9778413d70e41a901c7b528382c24bda22f45cffff84ffecde43821c7a24a96660cda6117794187c98b0f6f1ba61e7966e9d7557e27d2bd9
|
@@ -2,32 +2,34 @@ module ActiveRecord
|
|
2
2
|
module QuickRead
|
3
3
|
module LiteBase
|
4
4
|
def method_missing(name, *args, &block)
|
5
|
-
return super unless
|
5
|
+
return super unless _ar_instance.respond_to?(name)
|
6
6
|
|
7
|
-
|
7
|
+
_ar_instance.send(name, *args, &block)
|
8
8
|
end
|
9
9
|
|
10
10
|
def respond_to_missing?(*args)
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def subject
|
15
|
-
@subject ||= model.from_hash(to_h)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Since the struct that includes this module is defined within the model's namespace
|
19
|
-
def model
|
20
|
-
self.class.module_parent
|
11
|
+
_ar_instance.respond_to?(*args) || super
|
21
12
|
end
|
22
13
|
|
23
14
|
def reload(*)
|
24
|
-
source = @
|
25
|
-
source ||=
|
15
|
+
source = @_ar_instance&.reload
|
16
|
+
source ||= _ar_model.unscoped.where(id: id).quick_read
|
26
17
|
return false unless source
|
27
18
|
|
28
19
|
members.each { |attr| send(:"#{attr}=", source.send(attr)) }
|
29
20
|
self
|
30
21
|
end
|
22
|
+
|
23
|
+
# Private
|
24
|
+
|
25
|
+
def _ar_instance
|
26
|
+
@_ar_instance ||= _ar_model.from_hash(to_h)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Since the struct that includes this module is defined within the model's namespace
|
30
|
+
def _ar_model
|
31
|
+
self.class.module_parent
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|