active_record_abstract_class 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b18a288c45a3a3c80e99512a9b6f4709d2f22d5
4
+ data.tar.gz: 94284472d76ee856bbbea6fd33e383fac5f3fc38
5
+ SHA512:
6
+ metadata.gz: 2d560e2c02bf0c68284c655538ffe01ad63c3c2332c61997842f002016e59682f9c7e1332113453a06451850d3dd2bd8bbbbe3a40666f80d0cc6591467eb4cc0
7
+ data.tar.gz: c4d6e73475a7746bdd228184b4c24e9865b8578c3e49d47dae92cd612a7f95996dc89fb48d7c23078e8b408ae5425cb69619eca6369cd8e6bf1397b713efb742
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 enable-labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ active_record_abstract_class
2
+ ============================
3
+
4
+ Disallow persistence of ActiveRecord models with by including a module
5
+
6
+ Use
7
+ ---
8
+
9
+ Install the gem, then `include ActiveRecordAbstractClass` in any model you wish to make abstract. Child classes are not abstract unless `ActiveRecordAbstractClass` is included in them as well.
10
+
11
+ Purpose
12
+ -------
13
+
14
+ This module can be included in ActiveRecord classes to make them non-persistable. It was created to duplicate the functionality of "abstract" classes present in other languages within the context of ActiveRecord persistence. The intended use was to allow extraction of common methods shared by several STI models in a Rails project into the base class, while making the base class very difficult to persist.
15
+
16
+ Limitations
17
+ -----------
18
+
19
+ Including this module does not prevent ambitious programmers from finding ways around it. Ruby allows one to monkey patch past the protections afforded by this gem. Not quite the same thing as a real abstract class!
@@ -0,0 +1,25 @@
1
+ require 'active_record_abstract_class/version'
2
+
3
+ module ActiveRecordAbstractClass
4
+ module ClassMethods
5
+ def abstract?
6
+ @abstract == true
7
+ end
8
+ end
9
+
10
+ def self.included (base)
11
+ base.module_eval do
12
+ before_save :do_not_persist_abstract_class
13
+ end
14
+
15
+ base.extend(ClassMethods)
16
+
17
+ base.instance_eval do
18
+ @abstract = true
19
+ end
20
+ end
21
+
22
+ def do_not_persist_abstract_class
23
+ raise "#{self.class.name} is an abstract class and can't be persisted" if self.class.abstract?
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveRecordAbstractClass
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_record_abstract_class
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Enable Labs
8
+ - Jonathan Chapman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2014-06-19 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Make ActiveRecord classes non-persistable with a module
17
+ email:
18
+ - sa@enablelabs.com
19
+ - chapmajs@gmail.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - LICENSE
28
+ - README.md
29
+ - lib/active_record_abstract_class.rb
30
+ - lib/active_record_abstract_class/version.rb
31
+ homepage: https://github.com/enable-labs/active_record_abstract_class
32
+ licenses:
33
+ - MIT
34
+ metadata: {}
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - &id001
44
+ - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - *id001
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 2.2.2
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: ActiveRecord abstract class
57
+ test_files: []
58
+