rails_model_load_hook 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -0
- data/MIT-LICENSE +1 -1
- data/README.md +39 -0
- data/Rakefile +5 -22
- data/app/assets/config/rails_model_load_hook_manifest.js +1 -0
- data/app/assets/stylesheets/rails_model_load_hook/application.css +15 -0
- data/app/controllers/rails_model_load_hook/application_controller.rb +4 -0
- data/app/helpers/rails_model_load_hook/application_helper.rb +4 -0
- data/app/jobs/rails_model_load_hook/application_job.rb +4 -0
- data/app/mailers/rails_model_load_hook/application_mailer.rb +6 -0
- data/app/models/concerns/rails_model_load_hook/active_record.rb +13 -0
- data/app/models/rails_model_load_hook/application_record.rb +5 -0
- data/app/views/layouts/rails_model_load_hook/application.html.erb +15 -0
- data/config/initializers/active_record.rb +3 -0
- data/config/routes.rb +2 -0
- data/lib/rails_model_load_hook/authors.rb +15 -0
- data/lib/rails_model_load_hook/version.rb +1 -1
- data/lib/rails_model_load_hook.rb +3 -2
- metadata +26 -26
- data/README.rdoc +0 -22
- data/lib/rails_model_load_hook/active_record/on_load.rb +0 -17
- data/lib/rails_model_load_hook/active_record.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca5a48ab0dbd99da441b2fef0417d43580b1379250c91547dfbd7cea9504a157
|
4
|
+
data.tar.gz: f9327ebcd7bbdd5a32c619cf263763bd032e7be0047a00c4b05f53fa12bcc8d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca66983d5cab757e9b68c0f9fc80421faa774ff004788c7f6f7b5723b6eab79ada2cc6aa7d026fa61879d7dce43b4984cd5054a00ca04ec4b8faf371fd9d641
|
7
|
+
data.tar.gz: 5892f028531238fc9cb1b5faeed6778ab18ad6919520f8418a58efc2365c16caa4ee4f4f915b8de7be0427f247c85d432019606326dfe53832a0e4528f5f8826
|
data/CHANGELOG.md
ADDED
File without changes
|
data/MIT-LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Rails Model Load Hook
|
2
|
+
|
3
|
+
Adds `:model_class` loading hook for every `ActiveRecord` descendant.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
ActiveSupport.on_load :model_class do
|
9
|
+
# The code for your model class goes here…
|
10
|
+
end
|
11
|
+
```
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "rails_model_load_hook"
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
```bash
|
27
|
+
$ gem install rails_model_load_hook
|
28
|
+
```
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
37
|
+
|
38
|
+
## License
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
1
|
+
require "bundler/setup"
|
14
2
|
|
15
|
-
|
16
|
-
|
17
|
-
rdoc.title = 'RailsModelLoadHook'
|
18
|
-
rdoc.options << '--line-numbers'
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
3
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
4
|
+
load "rails/tasks/engine.rake"
|
22
5
|
|
6
|
+
load "rails/tasks/statistics.rake"
|
23
7
|
|
24
|
-
|
25
|
-
|
8
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/rails_model_load_hook .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Rails model load hook</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag "rails_model_load_hook/application", media: "all" %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Author ||= Struct.new(
|
2
|
+
:name,
|
3
|
+
:email,
|
4
|
+
:github_url,
|
5
|
+
)
|
6
|
+
|
7
|
+
module RailsModelLoadHook
|
8
|
+
AUTHORS = [
|
9
|
+
Gem::Author.new(
|
10
|
+
name: 'Alexander Senko',
|
11
|
+
email: 'Alexander.Senko@gmail.com',
|
12
|
+
github_url: 'https://github.com/Alexander-Senko',
|
13
|
+
),
|
14
|
+
]
|
15
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_model_load_hook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Senko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sqlite3
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: '7.1'
|
41
27
|
description: Adds :model_class load hook for every ActiveRecord descendant.
|
42
28
|
email:
|
43
29
|
- Alexander.Senko@gmail.com
|
@@ -45,19 +31,33 @@ executables: []
|
|
45
31
|
extensions: []
|
46
32
|
extra_rdoc_files: []
|
47
33
|
files:
|
34
|
+
- CHANGELOG.md
|
48
35
|
- MIT-LICENSE
|
49
|
-
- README.
|
36
|
+
- README.md
|
50
37
|
- Rakefile
|
38
|
+
- app/assets/config/rails_model_load_hook_manifest.js
|
39
|
+
- app/assets/stylesheets/rails_model_load_hook/application.css
|
40
|
+
- app/controllers/rails_model_load_hook/application_controller.rb
|
41
|
+
- app/helpers/rails_model_load_hook/application_helper.rb
|
42
|
+
- app/jobs/rails_model_load_hook/application_job.rb
|
43
|
+
- app/mailers/rails_model_load_hook/application_mailer.rb
|
44
|
+
- app/models/concerns/rails_model_load_hook/active_record.rb
|
45
|
+
- app/models/rails_model_load_hook/application_record.rb
|
46
|
+
- app/views/layouts/rails_model_load_hook/application.html.erb
|
47
|
+
- config/initializers/active_record.rb
|
48
|
+
- config/routes.rb
|
51
49
|
- lib/rails_model_load_hook.rb
|
52
|
-
- lib/rails_model_load_hook/
|
53
|
-
- lib/rails_model_load_hook/active_record/on_load.rb
|
50
|
+
- lib/rails_model_load_hook/authors.rb
|
54
51
|
- lib/rails_model_load_hook/engine.rb
|
55
52
|
- lib/rails_model_load_hook/version.rb
|
56
53
|
- lib/tasks/rails_model_load_hook_tasks.rake
|
57
54
|
homepage: https://github.com/Alexander-Senko/rails_model_load_hook
|
58
55
|
licenses:
|
59
56
|
- MIT
|
60
|
-
metadata:
|
57
|
+
metadata:
|
58
|
+
homepage_uri: https://github.com/Alexander-Senko/rails_model_load_hook
|
59
|
+
source_code_uri: https://github.com/Alexander-Senko/rails_model_load_hook
|
60
|
+
changelog_uri: https://github.com/Alexander-Senko/rails_model_load_hook/CHANGELOG.md
|
61
61
|
post_install_message:
|
62
62
|
rdoc_options: []
|
63
63
|
require_paths:
|
@@ -66,14 +66,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2.
|
69
|
+
version: '2.7'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.5.0.dev
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Load hook for Rails model classes.
|
data/README.rdoc
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
= Loading hook for Rails models
|
2
|
-
|
3
|
-
Adds <tt>:model_class</tt> loading hook for every <tt>ActiveRecord</tt> descendant.
|
4
|
-
|
5
|
-
|
6
|
-
== Installation
|
7
|
-
|
8
|
-
Just include the gem in <tt>Gemfile</tt> and <tt>bundle</tt> it.
|
9
|
-
|
10
|
-
|
11
|
-
== Usage
|
12
|
-
|
13
|
-
ActiveSupport.on_load :model_class do
|
14
|
-
# Put the code for your model here
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
== License
|
19
|
-
|
20
|
-
This project uses MIT-LICENSE.
|
21
|
-
|
22
|
-
© Alexander Senko, SoftPro Ltd.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
|
-
module RailsModelLoadHook::ActiveRecord
|
4
|
-
module OnLoad
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
private
|
9
|
-
|
10
|
-
def inherited child
|
11
|
-
super
|
12
|
-
|
13
|
-
ActiveSupport.run_load_hooks :model_class, child
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|