activerecord-records_on_load 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -5
- data/lib/active_record/records_on_load.rb +4 -2
- data/lib/activerecord-records_on_load/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e6595644a9ff567d8112ea141c9c38bdc63ab15
|
4
|
+
data.tar.gz: faf2f163b4307c8225910d17b2fae79d68f94c8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea5daf395ee4155841cfabd96a666737e9cc79563e2098d434d9606d04fae73c3b7a883cd85bd35c0bac0f9f4f655f901504f32b436cd0971fd99ca78198c0c7
|
7
|
+
data.tar.gz: ad27de72d8a94388f205a50d5b6b680bfa4007ac76f5acc4b5260a7023916e007d4055fa24c9e84c0c0ae7a5aadec8cc8adf65c84b692e1e3e427f048ae5f0a0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Activerecord::RecordsOnLoad
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activerecord/records_on_load`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -28,7 +24,10 @@ User.all.on_load do |records|
|
|
28
24
|
end
|
29
25
|
|
30
26
|
User.all.on_load do |records|
|
31
|
-
ActiveRecord::Associations::Preloader.new.preload(
|
27
|
+
ActiveRecord::Associations::Preloader.new.preload(
|
28
|
+
records.select(&:admin?),
|
29
|
+
:role
|
30
|
+
)
|
32
31
|
end
|
33
32
|
```
|
34
33
|
|
@@ -4,7 +4,9 @@ module ActiveRecord
|
|
4
4
|
super(&block)
|
5
5
|
|
6
6
|
if @_on_load_blocks.present?
|
7
|
-
@_on_load_blocks.each
|
7
|
+
@_on_load_blocks.each do |b|
|
8
|
+
b.call(@records)
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
self
|
@@ -13,7 +15,7 @@ module ActiveRecord
|
|
13
15
|
def on_load(&block)
|
14
16
|
@_on_load_blocks ||= []
|
15
17
|
@_on_load_blocks << block
|
16
|
-
|
18
|
+
clone
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-records_on_load
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun0kada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|