columns_on_demand 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -3
- data/lib/columns_on_demand.rb +14 -14
- data/lib/columns_on_demand/version.rb +1 -1
- metadata +5 -5
data/README
CHANGED
@@ -21,8 +21,10 @@ Compatibility
|
|
21
21
|
|
22
22
|
Supports mysql, mysql2, postgresql, and sqlite3.
|
23
23
|
|
24
|
-
Currently tested against Rails 2.
|
25
|
-
|
24
|
+
Currently tested against Rails 3.2.13 and 3.1.8, on Ruby 1.8.7 and 2.0.0p0.
|
25
|
+
Was also tested compatible with 2.3.14, 3.0.17.
|
26
|
+
|
27
|
+
Note that 3.0 and 3.1 have ActiveRecord regressions that will affect sqlite users.
|
26
28
|
|
27
29
|
|
28
30
|
Example
|
@@ -42,4 +44,4 @@ class Example
|
|
42
44
|
end
|
43
45
|
|
44
46
|
|
45
|
-
Copyright (c) 2008-
|
47
|
+
Copyright (c) 2008-2013 Will Bryant, Sekuda Ltd, released under the MIT license
|
data/lib/columns_on_demand.rb
CHANGED
@@ -7,20 +7,6 @@ module ColumnsOnDemand
|
|
7
7
|
extend ClassMethods
|
8
8
|
include InstanceMethods
|
9
9
|
|
10
|
-
if ActiveRecord::VERSION::MAJOR > 2
|
11
|
-
relation # set up @relation
|
12
|
-
class << @relation # but always modify @relation, not the temporary returned by .relation if there's a where(type condition)
|
13
|
-
def build_select_with_columns_on_demand(arel, selects)
|
14
|
-
unless selects.empty?
|
15
|
-
build_select_without_columns_on_demand(arel, selects)
|
16
|
-
else
|
17
|
-
arel.project(Arel::SqlLiteral.new(@klass.default_select(true)))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
alias_method_chain :build_select, :columns_on_demand
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
10
|
class <<self
|
25
11
|
unless ActiveRecord.const_defined?(:AttributeMethods) &&
|
26
12
|
ActiveRecord::AttributeMethods::const_defined?(:Serialization) &&
|
@@ -140,6 +126,20 @@ module ColumnsOnDemand
|
|
140
126
|
end
|
141
127
|
end
|
142
128
|
end
|
129
|
+
|
130
|
+
module RelationMethods
|
131
|
+
def build_select_with_columns_on_demand(arel, selects)
|
132
|
+
if selects.empty?
|
133
|
+
build_select_without_columns_on_demand(arel, default_select(true))
|
134
|
+
else
|
135
|
+
build_select_without_columns_on_demand(arel, selects)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
143
139
|
end
|
144
140
|
|
145
141
|
ActiveRecord::Base.send(:extend, ColumnsOnDemand::BaseMethods)
|
142
|
+
if ActiveRecord.const_defined?(:Relation)
|
143
|
+
ActiveRecord::Relation.send(:include, ColumnsOnDemand::RelationMethods)
|
144
|
+
ActiveRecord::Relation.alias_method_chain :build_select, :columns_on_demand
|
145
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: columns_on_demand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version:
|
9
|
+
- 0
|
10
|
+
version: 3.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Will Bryant
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-04-20 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|