active_record_composition 0.0.1 → 0.0.2
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.
- data/lib/active_record_composition.rb +11 -8
- metadata +8 -8
@@ -22,20 +22,23 @@ module ActiveRecordComposition
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def method_missing(method, *args, &block)
|
25
|
-
|
25
|
+
begin
|
26
|
+
active_composite.send method, *args, &block
|
27
|
+
rescue
|
28
|
+
super.method_missing method, *args, &block
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
end
|
29
33
|
|
34
|
+
def self.create_class(class_name, superclass, &block)
|
35
|
+
klass = Class.new superclass, &block
|
36
|
+
Object.const_set class_name, klass
|
37
|
+
end
|
38
|
+
|
30
39
|
def self.included(base)
|
31
40
|
base.extend(ClassMethods)
|
32
|
-
base.active_composite =
|
33
|
-
def is_a?(compared)
|
34
|
-
return true if (self.class.name.gsub('ActiveComposite', '') == compared.name)
|
35
|
-
super.is_a? compared
|
36
|
-
end
|
37
|
-
end)
|
38
|
-
base.active_composite.table_name = "#{base.name}s".underscore
|
41
|
+
base.active_composite = create_class("#{base.name}", ActiveRecord::Base)
|
39
42
|
end
|
40
43
|
|
41
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_composition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement: &
|
16
|
+
requirement: &16522700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,13 +21,13 @@ dependencies:
|
|
21
21
|
version: 3.2.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16522700
|
25
25
|
description: ActiveRecord is awesome, inheritance is not always so awesome. This gem
|
26
26
|
is for people who want to use ActiveRecord but don't want to be forced to use inheritance
|
27
|
-
in their models. Magic stuff happens that keeps the ActiveRecord::Base
|
28
|
-
away from your model object graph until runtime but you can still use
|
29
|
-
methods on your model as you're accustomed to. Also, you now
|
30
|
-
slot freed up - easy peasy :-)
|
27
|
+
of ActiveRecord:Base in their models. Magic stuff happens that keeps the ActiveRecord::Base
|
28
|
+
relationship away from your model object graph until runtime but you can still use
|
29
|
+
all the ActiveRecord methods on your model as you're accustomed to. Also, you now
|
30
|
+
have an inheritance slot freed up - easy peasy :-)
|
31
31
|
email: kevin.beddingfield@gmail.com
|
32
32
|
executables: []
|
33
33
|
extensions: []
|