store_base_sti_class_for_3_0 0.1.2 → 0.1.3
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/Gemfile +1 -1
- data/Gemfile.lock +10 -10
- data/VERSION +1 -1
- data/lib/store_base_sti_class_for_3_0.rb +4 -0
- data/lib/store_base_sti_class_for_3_1.rb +31 -0
- data/store_base_sti_class_for_3_0.gemspec +10 -10
- metadata +33 -34
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (3.0.
|
5
|
-
activesupport (= 3.0.
|
4
|
+
activemodel (3.0.7)
|
5
|
+
activesupport (= 3.0.7)
|
6
6
|
builder (~> 2.1.2)
|
7
7
|
i18n (~> 0.5.0)
|
8
|
-
activerecord (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
8
|
+
activerecord (3.0.7)
|
9
|
+
activemodel (= 3.0.7)
|
10
|
+
activesupport (= 3.0.7)
|
11
11
|
arel (~> 2.0.2)
|
12
12
|
tzinfo (~> 0.3.23)
|
13
|
-
activesupport (3.0.
|
14
|
-
arel (2.0.
|
13
|
+
activesupport (3.0.7)
|
14
|
+
arel (2.0.10)
|
15
15
|
builder (2.1.2)
|
16
16
|
git (1.2.5)
|
17
17
|
i18n (0.5.0)
|
@@ -20,15 +20,15 @@ GEM
|
|
20
20
|
git (>= 1.2.5)
|
21
21
|
rake
|
22
22
|
mysql2 (0.2.6)
|
23
|
-
rake (0.
|
23
|
+
rake (0.9.1)
|
24
24
|
rcov (0.9.9)
|
25
|
-
tzinfo (0.3.
|
25
|
+
tzinfo (0.3.27)
|
26
26
|
|
27
27
|
PLATFORMS
|
28
28
|
ruby
|
29
29
|
|
30
30
|
DEPENDENCIES
|
31
|
-
activerecord (
|
31
|
+
activerecord (>= 3.0.5)
|
32
32
|
bundler (~> 1.0.0)
|
33
33
|
jeweler (~> 1.5.2)
|
34
34
|
mysql2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'active_record'
|
2
|
+
|
3
|
+
if ActiveRecord::VERSION::STRING =~ /^3\.0/
|
2
4
|
require 'active_record/associations'
|
3
5
|
require 'active_record/reflection'
|
4
6
|
require 'active_record/association_preload'
|
@@ -463,4 +465,6 @@ module ActiveRecord
|
|
463
465
|
end
|
464
466
|
end
|
465
467
|
end
|
468
|
+
end
|
469
|
+
|
466
470
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
if ActiveRecord::VERSION::STRING =~ /^3\.1/
|
4
|
+
require 'active_record/reflection'
|
5
|
+
require 'active_record/associations'
|
6
|
+
require 'active_record/associations/belongs_to_polymorphic_association'
|
7
|
+
|
8
|
+
module ActiveRecord
|
9
|
+
module Reflection # :nodoc:
|
10
|
+
class AssociationReflection
|
11
|
+
def foreign_subtype
|
12
|
+
@foreign_subtype ||= options[:foreign_subtype] || "#{name}_subtype"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# = Active Record Belongs To Polymorphic Association
|
18
|
+
module Associations
|
19
|
+
class BelongsToPolymorphicAssociation < BelongsToAssociation #:nodoc:
|
20
|
+
private
|
21
|
+
|
22
|
+
def replace_keys(record)
|
23
|
+
super
|
24
|
+
owner[reflection.foreign_type] = record && record.class.base_class.name
|
25
|
+
owner[reflection.foreign_subtype] = record && record.class.sti_name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{store_base_sti_class_for_3_0}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{Paul Kmiec}]
|
12
|
+
s.date = %q{2011-06-02}
|
13
13
|
s.description = %q{
|
14
14
|
ActiveRecord has always stored the base class in polymorphic _type columns when using STI. This can have non-trivial
|
15
15
|
performance implications in certain cases. This gem adds 'store_base_sti_class' configuration options which controls
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"Rakefile",
|
31
31
|
"VERSION",
|
32
32
|
"lib/store_base_sti_class_for_3_0.rb",
|
33
|
+
"lib/store_base_sti_class_for_3_1.rb",
|
33
34
|
"polymorphic_and_sti_fix_for_rails_2.3-1.diff",
|
34
35
|
"polymorphic_and_sti_fix_for_rails_2.3-2.diff",
|
35
36
|
"store_base_sti_class_for_3_0.gemspec",
|
@@ -40,9 +41,9 @@ Gem::Specification.new do |s|
|
|
40
41
|
"test/test_store_base_sti_class_for_3_0.rb"
|
41
42
|
]
|
42
43
|
s.homepage = %q{http://github.com/pkmiec/store_base_sti_class_for_3_0}
|
43
|
-
s.licenses = [
|
44
|
-
s.require_paths = [
|
45
|
-
s.rubygems_version = %q{1.
|
44
|
+
s.licenses = [%q{MIT}]
|
45
|
+
s.require_paths = [%q{lib}]
|
46
|
+
s.rubygems_version = %q{1.8.4}
|
46
47
|
s.summary = %q{Modifies ActiveRecord 3.0.x with the ability to store the actual class (instead of the base class) in polymorhic _type columns when using STI}
|
47
48
|
s.test_files = [
|
48
49
|
"test/connection.rb",
|
@@ -53,24 +54,23 @@ Gem::Specification.new do |s|
|
|
53
54
|
]
|
54
55
|
|
55
56
|
if s.respond_to? :specification_version then
|
56
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
57
57
|
s.specification_version = 3
|
58
58
|
|
59
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_runtime_dependency(%q<activerecord>, ["
|
60
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.5"])
|
61
61
|
s.add_development_dependency(%q<mysql2>, [">= 0"])
|
62
62
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
63
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
64
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
65
65
|
else
|
66
|
-
s.add_dependency(%q<activerecord>, ["
|
66
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.5"])
|
67
67
|
s.add_dependency(%q<mysql2>, [">= 0"])
|
68
68
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
69
69
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
70
70
|
s.add_dependency(%q<rcov>, [">= 0"])
|
71
71
|
end
|
72
72
|
else
|
73
|
-
s.add_dependency(%q<activerecord>, ["
|
73
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.5"])
|
74
74
|
s.add_dependency(%q<mysql2>, [">= 0"])
|
75
75
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
76
76
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_base_sti_class_for_3_0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Kmiec
|
@@ -15,17 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-06-02 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
type: :runtime
|
24
|
-
name: activerecord
|
25
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
22
|
none: false
|
27
23
|
requirements:
|
28
|
-
- -
|
24
|
+
- - ">="
|
29
25
|
- !ruby/object:Gem::Version
|
30
26
|
hash: 13
|
31
27
|
segments:
|
@@ -33,12 +29,12 @@ dependencies:
|
|
33
29
|
- 0
|
34
30
|
- 5
|
35
31
|
version: 3.0.5
|
36
|
-
|
37
|
-
|
32
|
+
type: :runtime
|
33
|
+
name: activerecord
|
38
34
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
38
|
none: false
|
43
39
|
requirements:
|
44
40
|
- - ">="
|
@@ -47,12 +43,12 @@ dependencies:
|
|
47
43
|
segments:
|
48
44
|
- 0
|
49
45
|
version: "0"
|
50
|
-
requirement: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
prerelease: false
|
53
46
|
type: :development
|
54
|
-
name:
|
55
|
-
|
47
|
+
name: mysql2
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
52
|
none: false
|
57
53
|
requirements:
|
58
54
|
- - ~>
|
@@ -63,12 +59,12 @@ dependencies:
|
|
63
59
|
- 0
|
64
60
|
- 0
|
65
61
|
version: 1.0.0
|
66
|
-
requirement: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
prerelease: false
|
69
62
|
type: :development
|
70
|
-
name:
|
71
|
-
|
63
|
+
name: bundler
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
68
|
none: false
|
73
69
|
requirements:
|
74
70
|
- - ~>
|
@@ -79,12 +75,12 @@ dependencies:
|
|
79
75
|
- 5
|
80
76
|
- 2
|
81
77
|
version: 1.5.2
|
82
|
-
requirement: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
prerelease: false
|
85
78
|
type: :development
|
86
|
-
name:
|
87
|
-
|
79
|
+
name: jeweler
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
84
|
none: false
|
89
85
|
requirements:
|
90
86
|
- - ">="
|
@@ -93,7 +89,10 @@ dependencies:
|
|
93
89
|
segments:
|
94
90
|
- 0
|
95
91
|
version: "0"
|
96
|
-
|
92
|
+
type: :development
|
93
|
+
name: rcov
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: *id005
|
97
96
|
description: "\n ActiveRecord has always stored the base class in polymorphic _type columns when using STI. This can have non-trivial\n performance implications in certain cases. This gem adds 'store_base_sti_class' configuration options which controls\n whether ActiveRecord will store the base class or the actual class. Default to true for backwards compatibility.\n "
|
98
97
|
email: paul.kmiec@appfolio.com
|
99
98
|
executables: []
|
@@ -113,6 +112,7 @@ files:
|
|
113
112
|
- Rakefile
|
114
113
|
- VERSION
|
115
114
|
- lib/store_base_sti_class_for_3_0.rb
|
115
|
+
- lib/store_base_sti_class_for_3_1.rb
|
116
116
|
- polymorphic_and_sti_fix_for_rails_2.3-1.diff
|
117
117
|
- polymorphic_and_sti_fix_for_rails_2.3-2.diff
|
118
118
|
- store_base_sti_class_for_3_0.gemspec
|
@@ -121,7 +121,6 @@ files:
|
|
121
121
|
- test/models.rb
|
122
122
|
- test/schema.rb
|
123
123
|
- test/test_store_base_sti_class_for_3_0.rb
|
124
|
-
has_rdoc: true
|
125
124
|
homepage: http://github.com/pkmiec/store_base_sti_class_for_3_0
|
126
125
|
licenses:
|
127
126
|
- MIT
|
@@ -151,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
150
|
requirements: []
|
152
151
|
|
153
152
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.
|
153
|
+
rubygems_version: 1.8.4
|
155
154
|
signing_key:
|
156
155
|
specification_version: 3
|
157
156
|
summary: Modifies ActiveRecord 3.0.x with the ability to store the actual class (instead of the base class) in polymorhic _type columns when using STI
|