activerecord-quick_read 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 568374965e9c8f4084e7b8e5da2ea6d300c7100833dd4bd49c76053aa0cf9c41
|
4
|
+
data.tar.gz: 45733a42147cff2340617a7b3d67b917b4d9b2eb4cfe2b39ae74774a567e0bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d472db41e9d176750b839d54981a662decb9a6ebf93341d531750240d9f3927208e41ad71c168314b1ad29d105a91346f1615d9cec1d7d1f4875bcce941488
|
7
|
+
data.tar.gz: 44587f0a0d78e5f883c68af80d48ea00ed1fd64e8368b8621c3bbc7cf21e399f4a1244e7294bbda8702ac5c5cc5d7c56f5337d49ea1c84de47025a6581b138bd
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module QuickRead
|
3
|
+
module LiteBase
|
4
|
+
def method_missing(name, *args, &block)
|
5
|
+
return super unless subject.respond_to?(name)
|
6
|
+
|
7
|
+
subject.send(name, *args, &block)
|
8
|
+
end
|
9
|
+
|
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
|
21
|
+
end
|
22
|
+
|
23
|
+
def reload(*)
|
24
|
+
source = @subject&.reload
|
25
|
+
source ||= model.unscoped.where(id: id).select(members.join(', ')).quick_read
|
26
|
+
return false unless source
|
27
|
+
|
28
|
+
members.each { |attr| send(:"#{attr}=", source.send(attr)) }
|
29
|
+
self
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "active_record"
|
3
4
|
|
4
5
|
require_relative "quick_read/version"
|
6
|
+
require_relative "quick_read/lite_base"
|
5
7
|
require_relative "quick_read/railtie" if defined?(Rails)
|
6
8
|
|
7
9
|
module ActiveRecord
|
@@ -73,26 +75,5 @@ module ActiveRecord
|
|
73
75
|
def from_hash(attributes)
|
74
76
|
allocate.init_with_attributes(attributes_builder.build_from_database(attributes.stringify_keys!))
|
75
77
|
end
|
76
|
-
|
77
|
-
module LiteBase
|
78
|
-
def method_missing(name, *args, &block)
|
79
|
-
return super unless subject.respond_to?(name)
|
80
|
-
|
81
|
-
subject.send(name, *args, &block)
|
82
|
-
end
|
83
|
-
|
84
|
-
def respond_to_missing?(*args)
|
85
|
-
subject.respond_to?(*args) || super
|
86
|
-
end
|
87
|
-
|
88
|
-
def subject
|
89
|
-
@subject ||= model.from_hash(to_h)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Since the struct that includes this module is defined within the model's namespace
|
93
|
-
def model
|
94
|
-
self.class.module_parent
|
95
|
-
end
|
96
|
-
end
|
97
78
|
end
|
98
79
|
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: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
@@ -48,8 +48,8 @@ files:
|
|
48
48
|
- LICENSE.txt
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
-
- activerecord-quick_read.gemspec
|
52
51
|
- lib/activerecord/quick_read.rb
|
52
|
+
- lib/activerecord/quick_read/lite_base.rb
|
53
53
|
- lib/activerecord/quick_read/railtie.rb
|
54
54
|
- lib/activerecord/quick_read/version.rb
|
55
55
|
homepage: https://github.com/ridiculous/activerecord-quick_reads
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/activerecord/quick_read/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "activerecord-quick_read"
|
7
|
-
spec.version = ActiveRecord::QuickRead::VERSION
|
8
|
-
spec.authors = ["Ryan Buckley"]
|
9
|
-
spec.email = ["ridiculous@hey.com"]
|
10
|
-
|
11
|
-
spec.summary = "Makes rails go _faster_. Improve read times 4x!"
|
12
|
-
spec.description = "Makes rails go _faster_. Improve read times 4x!"
|
13
|
-
spec.homepage = "https://github.com/ridiculous/activerecord-quick_reads"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.6.0"
|
16
|
-
|
17
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = "https://github.com/ridiculous/activerecord-quick_reads"
|
21
|
-
spec.metadata["changelog_uri"] = "https://github.com/ridiculous/activerecord-quick_reads/CHANGELOG.md"
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(__dir__) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
# Uncomment to register a new dependency of your gem
|
35
|
-
spec.add_dependency "activerecord", ">= 5", "<= 8"
|
36
|
-
|
37
|
-
# For more information and examples about making a new gem, check out our
|
38
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
-
end
|