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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7234e9dcb7b3d4690c49318d07af329d46f031e50d63450a24b57303314f389
4
- data.tar.gz: 9517bccc29ba46045530c4028a7be33db00d84d15ad18e6d38561e7d3ec4e83e
3
+ metadata.gz: 0d401b9ac50f22d00aeecc23fa0b526b6be514bd0ff16ef9b59de596e43b26ba
4
+ data.tar.gz: e62a73b6cd6295759857c0a1600bd012e552dcdf6594cb9512678296e627311c
5
5
  SHA512:
6
- metadata.gz: 27b36deba95df20b5bd391885e4582fa825d91f29a11c3125eab8be2eb2c525803d67dcaadac0cd0debd4bcb7f128a05aa7d43bcfe10e106f4b63ab6bdf22031
7
- data.tar.gz: bd9c2b8406e3f80c87d1267f18756915e81506a64f1df228b19c8240b69818ee9dece97f5774608e5e6403736ea0907f46860962b502fab4a0f98cb3ca2875bd
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 subject.respond_to?(name)
5
+ return super unless _ar_instance.respond_to?(name)
6
6
 
7
- subject.send(name, *args, &block)
7
+ _ar_instance.send(name, *args, &block)
8
8
  end
9
9
 
10
10
  def respond_to_missing?(*args)
11
- subject.respond_to?(*args) || super
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 = @subject&.reload
25
- source ||= model.unscoped.where(id: id).select(members.join(', ')).quick_read
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module QuickRead
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-quick_read
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley