includable-activerecord 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5aafdb8568666a7e73c1ae3680be19fd2d0d878
4
+ data.tar.gz: 001defdc541b3d2094a2a65281d8fd6064a7c2e6
5
+ SHA512:
6
+ metadata.gz: 65f5b4fce25b85bc5cf706346b9e6488c0914171a56f4feca7fde68253bbc11d647620b017c6b1912d5ce8f2de850de6bae99e8cde754a0950eef866769ae556
7
+ data.tar.gz: 7a4aa3b52ce9e815e3fe30a01a228db52a3446283955eebeb381253bb1c3c6d121d60bfb0d521f3a658c0083665c2ebdd3d32db6c3a21699361ef6dc0dffafa8
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in includable-activerecord.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Craig Buchek and BoochTek, LLC
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Includable::ActiveRecord
2
+
3
+ Build ActiveRecord models via module inclusion instead of class inheritance.
4
+
5
+ Since you're only allowed to inherit from a single class, it would be
6
+ preferable to include ActiveRecord as a module. This allows class
7
+ inheritance to be used for cases where there's an actually hierarchical
8
+ relationship.
9
+
10
+ This gem creates a module named `ActiveRecord::Model` that includes all
11
+ the same functionality as `ActiveRecord::Base`, including everything that
12
+ has been mixed into `ActiveRecord::Base`.
13
+
14
+
15
+ ## Usage
16
+
17
+ In your model, just include `ActiveRecord::Model`:
18
+
19
+ ```ruby
20
+ class User
21
+ include ActiveRecord::Model
22
+ # ...
23
+ end
24
+ ```
25
+
26
+ This is effectively equivalent to:
27
+
28
+ ```ruby
29
+ class User < ActiveRecord::Base
30
+ # ...
31
+ end
32
+ ```
33
+
34
+
35
+ ## Installation
36
+
37
+ Add this line to your application's Gemfile:
38
+
39
+ gem 'includable-activerecord'
40
+
41
+ And then execute:
42
+
43
+ $ bundle
44
+
45
+
46
+ ## TODO
47
+
48
+ * Add some tests. This is pretty simple, but we should test a few things.
49
+
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'includable/activerecord/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "includable-activerecord"
8
+ spec.version = Includable::ActiveRecord::VERSION
9
+ spec.authors = ["Craig Buchek"]
10
+ spec.email = ["craig@boochtek.com"]
11
+ spec.summary = %q{Build ActiveRecord models via module inclusion instead of class inheritance.}
12
+ spec.description = %q{Include ActiveRecord::Model in your model instead of inheriting from ActiveRecord::Base.}
13
+ spec.homepage = "https://github.com/boochtek/includable-activerecord"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency('activerecord', '~> 4.0.0')
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'activerecord/version'
2
+ require_relative 'activerecord/model'
@@ -0,0 +1,8 @@
1
+ # Suggested by http://stackoverflow.com/a/5197277.
2
+ unless Module.methods.include?(:extended_modules)
3
+ class Module
4
+ def extended_modules
5
+ (class << self; self end).included_modules
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'ext/module'
2
+
3
+ # Inclusion of this module is equivalent to subclassing from ActiveRecord::Base.
4
+ # In other words, these are effectively equivalent:
5
+ #
6
+ # class User
7
+ # include ActiveRecord::Model
8
+ # end
9
+ #
10
+ # class User < ActiveRecord::Base
11
+ # end
12
+ module ActiveRecord::Model
13
+ EXTENDED_MODULES = (ActiveRecord::Base.extended_modules - Object.extended_modules).reverse
14
+ INCLUDED_MODULES = (ActiveRecord::Base.included_modules - Object.included_modules).reverse
15
+
16
+ def self.included(base)
17
+ EXTENDED_MODULES.each{|mod| base.__send__(:extend, mod)}
18
+ INCLUDED_MODULES.each{|mod| base.__send__(:include, mod)}
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Includable
2
+ module ActiveRecord
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: includable-activerecord
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Craig Buchek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Include ActiveRecord::Model in your model instead of inheriting from
56
+ ActiveRecord::Base.
57
+ email:
58
+ - craig@boochtek.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - includable-activerecord.gemspec
69
+ - lib/includable/activerecord.rb
70
+ - lib/includable/activerecord/ext/module.rb
71
+ - lib/includable/activerecord/model.rb
72
+ - lib/includable/activerecord/version.rb
73
+ homepage: https://github.com/boochtek/includable-activerecord
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.14
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Build ActiveRecord models via module inclusion instead of class inheritance.
97
+ test_files: []