rails_model_load_hook 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19ca1dddc01a0f598676ba51059459065719eae7
4
+ data.tar.gz: d598657e3a3bf426bcde136400db406bd2575b21
5
+ SHA512:
6
+ metadata.gz: d8b189d61cd610424c57727d576edd0c22ef125e00e94ad152326da105c4b3d944dc47ff3be653a54af9adafe9f3c6132204259b49442f4a891906c5af958c6d
7
+ data.tar.gz: 4633c6f289c79d4fac550e07542fbdce9985ce8aad8f465965eab1cef10b1286bbd27064945e72e50d94fff499e387ac6b6a595e17543db0829a799682107c35
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Alexander Senko, SoftPro Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,22 @@
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.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env rake
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
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
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
22
+
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
@@ -0,0 +1,18 @@
1
+ require 'active_support/concern'
2
+
3
+ module RailsModelLoadHook::ActiveRecord
4
+ module OnLoad
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ singleton_class.alias_method_chain :inherited, :on_load
9
+ end
10
+
11
+ module ClassMethods
12
+ def inherited_with_on_load child
13
+ ActiveSupport.run_load_hooks :model_class, child
14
+ inherited_without_on_load child
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_model_load_hook/active_record/on_load'
2
+
3
+ ActiveSupport.on_load :active_record do
4
+ include RailsModelLoadHook::ActiveRecord::OnLoad
5
+ end
@@ -0,0 +1,5 @@
1
+ module RailsModelLoadHook
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RailsModelLoadHook
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module RailsModelLoadHook
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_model_load_hook/engine'
2
+ require 'rails_model_load_hook/active_record'
3
+
4
+ module RailsModelLoadHook
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc 'Explaining what the task does'
2
+ # task :rails_model_load_hook do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_model_load_hook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Senko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
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'
41
+ description: Adds :model_class load hook for every ActiveRecord descendant.
42
+ email:
43
+ - Alexander.Senko@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/tasks/rails_model_load_hook_tasks.rake
49
+ - lib/rails_model_load_hook.rb
50
+ - lib/rails_model_load_hook/version.rb
51
+ - lib/rails_model_load_hook/engine.rb
52
+ - lib/rails_model_load_hook/active_record/on_load.rb
53
+ - lib/rails_model_load_hook/active_record.rb
54
+ - MIT-LICENSE
55
+ - Rakefile
56
+ - README.rdoc
57
+ homepage: https://github.com/softpro/rails_model_load_hook
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.3
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Load hook for Rails model classes.
81
+ test_files: []