datagrid 1.4.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Gemfile +2 -2
- data/Rakefile +1 -0
- data/Readme.markdown +6 -0
- data/VERSION +1 -1
- data/datagrid.gemspec +92 -52
- data/lib/datagrid/columns.rb +18 -3
- data/lib/datagrid/columns/column.rb +27 -13
- data/lib/datagrid/core.rb +11 -2
- data/lib/datagrid/drivers/abstract_driver.rb +8 -0
- data/lib/datagrid/drivers/active_record.rb +8 -0
- data/lib/datagrid/drivers/array.rb +5 -1
- data/lib/datagrid/drivers/mongo_mapper.rb +8 -0
- data/lib/datagrid/drivers/mongoid.rb +9 -0
- data/lib/datagrid/drivers/sequel.rb +9 -0
- data/lib/datagrid/filters.rb +44 -8
- data/lib/datagrid/filters/base_filter.rb +11 -2
- data/lib/datagrid/filters/ranged_filter.rb +4 -2
- data/lib/datagrid/helper.rb +27 -4
- data/lib/datagrid/ordering.rb +5 -5
- data/lib/datagrid/renderer.rb +8 -4
- data/lib/datagrid/utils.rb +18 -0
- data/spec/datagrid/columns_spec.rb +45 -0
- data/spec/datagrid/core_spec.rb +23 -1
- data/spec/datagrid/filters/date_filter_spec.rb +9 -0
- data/spec/datagrid/filters/dynamic_filter_spec.rb +27 -1
- data/spec/datagrid/filters_spec.rb +49 -19
- data/spec/datagrid/helper_spec.rb +19 -0
- metadata +187 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dff6baaffd8e634c9e7d93754752f3389860060
|
4
|
+
data.tar.gz: f4f7c4d3092942e52f5d9c365c914e32b36b4fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa1c966c59b28eb7247e8fb8c660765e22608f3308153d3715610e5e45590b210cef2cd951dc1fe8f4e1489c3b4894623fd057b90f66be9b184b16bb510896de
|
7
|
+
data.tar.gz: 8a673590ea08d5618fac8f984ee56c5fbd61d8287aacf37caf7ff3cb2090c8b448d217603a67485aa28fc1d8402fe5fb8536cc1c75976369061a0362298e7829
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,11 +5,11 @@ gem "rails", ">= 3.2.22.2"
|
|
5
5
|
group :development do
|
6
6
|
|
7
7
|
gem "bundler"
|
8
|
-
gem "jeweler"
|
8
|
+
gem "jeweler", github: "technicalpickles/jeweler"
|
9
9
|
|
10
10
|
|
11
11
|
gem "debugger", :platform => :ruby_19
|
12
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22, :ruby_23] & Bundler::Dsl::VALID_PLATFORMS
|
12
|
+
gem "pry-byebug", :platform => [:ruby_20, :ruby_21, :ruby_22, :ruby_23] & Bundler::Dsl::VALID_PLATFORMS
|
13
13
|
|
14
14
|
gem "rspec", ">= 3"
|
15
15
|
gem "nokogiri" # used to test html output
|
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{This allows you to easily build datagrid aka data tables with sortable columns and filters}
|
22
22
|
gem.email = "agresso@gmail.com"
|
23
23
|
gem.authors = ["Bogdan Gusiev"]
|
24
|
+
gem.required_ruby_version = '>= 2.0'
|
24
25
|
# dependencies defined in Gemfile
|
25
26
|
end
|
26
27
|
Jeweler::RubygemsDotOrgTasks.new
|
data/Readme.markdown
CHANGED
@@ -20,6 +20,12 @@ Ruby library that helps you to build and represent table-like data with:
|
|
20
20
|
|
21
21
|
[Create an issue](https://github.com/bogdan/datagrid/issues/new) if you want more.
|
22
22
|
|
23
|
+
|
24
|
+
### Dependencies
|
25
|
+
|
26
|
+
* Ruby >= 2.0
|
27
|
+
* Rails >= 3.2
|
28
|
+
|
23
29
|
### Live Demo
|
24
30
|
|
25
31
|
[Datagrid DEMO application](http://datagrid.herokuapp.com) is available live!
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/datagrid.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: datagrid 1.
|
5
|
+
# stub: datagrid 1.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "datagrid"
|
9
|
-
s.version = "1.
|
8
|
+
s.name = "datagrid".freeze
|
9
|
+
s.version = "1.5.0"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Bogdan Gusiev"]
|
14
|
-
s.date = "2016-
|
15
|
-
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
|
16
|
-
s.email = "agresso@gmail.com"
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Bogdan Gusiev".freeze]
|
14
|
+
s.date = "2016-10-13"
|
15
|
+
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters".freeze
|
16
|
+
s.email = "agresso@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt"
|
19
19
|
]
|
@@ -126,57 +126,97 @@ Gem::Specification.new do |s|
|
|
126
126
|
"templates/grid.rb.erb",
|
127
127
|
"templates/index.html.erb"
|
128
128
|
]
|
129
|
-
s.homepage = "http://github.com/bogdan/datagrid"
|
130
|
-
s.licenses = ["MIT"]
|
131
|
-
s.
|
132
|
-
s.
|
129
|
+
s.homepage = "http://github.com/bogdan/datagrid".freeze
|
130
|
+
s.licenses = ["MIT".freeze]
|
131
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
|
132
|
+
s.rubygems_version = "2.6.7".freeze
|
133
|
+
s.summary = "Ruby gem to create datagrids".freeze
|
133
134
|
|
134
135
|
if s.respond_to? :specification_version then
|
135
136
|
s.specification_version = 4
|
136
137
|
|
137
138
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
138
|
-
s.add_runtime_dependency(%q<rails
|
139
|
-
s.
|
140
|
-
s.
|
141
|
-
s.
|
142
|
-
s.
|
143
|
-
s.
|
144
|
-
s.
|
145
|
-
s.
|
146
|
-
s.
|
147
|
-
s.
|
148
|
-
s.
|
149
|
-
s.
|
150
|
-
s.
|
139
|
+
s.add_runtime_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
140
|
+
s.add_runtime_dependency(%q<bundler>.freeze, [">= 0"])
|
141
|
+
s.add_runtime_dependency(%q<jeweler>.freeze, [">= 0"])
|
142
|
+
s.add_runtime_dependency(%q<debugger>.freeze, [">= 0"])
|
143
|
+
s.add_runtime_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
144
|
+
s.add_runtime_dependency(%q<rspec>.freeze, [">= 3"])
|
145
|
+
s.add_runtime_dependency(%q<nokogiri>.freeze, [">= 0"])
|
146
|
+
s.add_runtime_dependency(%q<sqlite3>.freeze, [">= 0"])
|
147
|
+
s.add_runtime_dependency(%q<sequel>.freeze, [">= 0"])
|
148
|
+
s.add_runtime_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
149
|
+
s.add_runtime_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
150
|
+
s.add_runtime_dependency(%q<bson>.freeze, [">= 0"])
|
151
|
+
s.add_runtime_dependency(%q<bson_ext>.freeze, [">= 0"])
|
152
|
+
s.add_development_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
153
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
154
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
155
|
+
s.add_development_dependency(%q<debugger>.freeze, [">= 0"])
|
156
|
+
s.add_development_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
157
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 3"])
|
158
|
+
s.add_development_dependency(%q<nokogiri>.freeze, [">= 0"])
|
159
|
+
s.add_development_dependency(%q<sqlite3>.freeze, [">= 0"])
|
160
|
+
s.add_development_dependency(%q<sequel>.freeze, [">= 0"])
|
161
|
+
s.add_development_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
162
|
+
s.add_development_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
163
|
+
s.add_development_dependency(%q<bson>.freeze, [">= 0"])
|
164
|
+
s.add_development_dependency(%q<bson_ext>.freeze, [">= 0"])
|
151
165
|
else
|
152
|
-
s.add_dependency(%q<rails
|
153
|
-
s.add_dependency(%q<bundler
|
154
|
-
s.add_dependency(%q<jeweler
|
155
|
-
s.add_dependency(%q<debugger
|
156
|
-
s.add_dependency(%q<byebug
|
157
|
-
s.add_dependency(%q<rspec
|
158
|
-
s.add_dependency(%q<nokogiri
|
159
|
-
s.add_dependency(%q<sqlite3
|
160
|
-
s.add_dependency(%q<sequel
|
161
|
-
s.add_dependency(%q<mongoid
|
162
|
-
s.add_dependency(%q<mongo_mapper
|
163
|
-
s.add_dependency(%q<bson
|
164
|
-
s.add_dependency(%q<bson_ext
|
166
|
+
s.add_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
167
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
168
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
169
|
+
s.add_dependency(%q<debugger>.freeze, [">= 0"])
|
170
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
171
|
+
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
172
|
+
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
173
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
174
|
+
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
175
|
+
s.add_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
176
|
+
s.add_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
177
|
+
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
178
|
+
s.add_dependency(%q<bson_ext>.freeze, [">= 0"])
|
179
|
+
s.add_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
180
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
181
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
182
|
+
s.add_dependency(%q<debugger>.freeze, [">= 0"])
|
183
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
184
|
+
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
185
|
+
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
186
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
187
|
+
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
188
|
+
s.add_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
189
|
+
s.add_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
190
|
+
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
191
|
+
s.add_dependency(%q<bson_ext>.freeze, [">= 0"])
|
165
192
|
end
|
166
193
|
else
|
167
|
-
s.add_dependency(%q<rails
|
168
|
-
s.add_dependency(%q<bundler
|
169
|
-
s.add_dependency(%q<jeweler
|
170
|
-
s.add_dependency(%q<debugger
|
171
|
-
s.add_dependency(%q<byebug
|
172
|
-
s.add_dependency(%q<rspec
|
173
|
-
s.add_dependency(%q<nokogiri
|
174
|
-
s.add_dependency(%q<sqlite3
|
175
|
-
s.add_dependency(%q<sequel
|
176
|
-
s.add_dependency(%q<mongoid
|
177
|
-
s.add_dependency(%q<mongo_mapper
|
178
|
-
s.add_dependency(%q<bson
|
179
|
-
s.add_dependency(%q<bson_ext
|
194
|
+
s.add_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
195
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
196
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
197
|
+
s.add_dependency(%q<debugger>.freeze, [">= 0"])
|
198
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
199
|
+
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
200
|
+
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
201
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
202
|
+
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
203
|
+
s.add_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
204
|
+
s.add_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
205
|
+
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
206
|
+
s.add_dependency(%q<bson_ext>.freeze, [">= 0"])
|
207
|
+
s.add_dependency(%q<rails>.freeze, [">= 3.2.22.2"])
|
208
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
209
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
210
|
+
s.add_dependency(%q<debugger>.freeze, [">= 0"])
|
211
|
+
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
212
|
+
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
213
|
+
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
214
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
215
|
+
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
216
|
+
s.add_dependency(%q<mongoid>.freeze, ["= 3.1.7"])
|
217
|
+
s.add_dependency(%q<mongo_mapper>.freeze, ["~> 0.13.0"])
|
218
|
+
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
219
|
+
s.add_dependency(%q<bson_ext>.freeze, [">= 0"])
|
180
220
|
end
|
181
221
|
end
|
182
222
|
|
data/lib/datagrid/columns.rb
CHANGED
@@ -119,6 +119,7 @@ module Datagrid
|
|
119
119
|
# * <tt>:after</tt> - determines the position of this column, by adding it after the column passed here
|
120
120
|
# * <tt>:if</tt> - the column is shown if the reult of calling this argument is true
|
121
121
|
# * <tt>:unless</tt> - the column is shown unless the reult of calling this argument is true
|
122
|
+
# * <tt>:preload</tt> - spefies which associations of the scope should be preloaded for this column
|
122
123
|
#
|
123
124
|
# See: https://github.com/bogdan/datagrid/wiki/Columns for examples
|
124
125
|
def column(name, options_or_query = {}, options = {}, &block)
|
@@ -225,7 +226,9 @@ module Datagrid
|
|
225
226
|
args.compact!
|
226
227
|
args.map!(&:to_sym)
|
227
228
|
columns.select do |column|
|
228
|
-
(!options[:data] || column.data?) &&
|
229
|
+
(!options[:data] || column.data?) &&
|
230
|
+
(!options[:html] || column.html?) &&
|
231
|
+
(column.mandatory? || args.empty? || args.include?(column.name))
|
229
232
|
end
|
230
233
|
end
|
231
234
|
|
@@ -240,7 +243,9 @@ module Datagrid
|
|
240
243
|
model.send(name)
|
241
244
|
end
|
242
245
|
position = Datagrid::Utils.extract_position_from_options(columns, options)
|
243
|
-
column = Datagrid::Columns::Column.new(
|
246
|
+
column = Datagrid::Columns::Column.new(
|
247
|
+
self, name, query, default_column_options.merge(options), &block
|
248
|
+
)
|
244
249
|
columns.insert(position, column)
|
245
250
|
end
|
246
251
|
|
@@ -256,7 +261,11 @@ module Datagrid
|
|
256
261
|
module InstanceMethods
|
257
262
|
|
258
263
|
def assets
|
259
|
-
|
264
|
+
append_column_preload(
|
265
|
+
driver.append_column_queries(
|
266
|
+
super, columns.select(&:query)
|
267
|
+
)
|
268
|
+
)
|
260
269
|
end
|
261
270
|
|
262
271
|
# Returns <tt>Array</tt> of human readable column names. See also "Localization" section
|
@@ -513,6 +522,12 @@ module Datagrid
|
|
513
522
|
|
514
523
|
protected
|
515
524
|
|
525
|
+
def append_column_preload(scope)
|
526
|
+
columns.inject(scope) do |current, column|
|
527
|
+
column.append_preload(current)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
516
531
|
def cache(column, asset, type)
|
517
532
|
@cache ||= {}
|
518
533
|
unless cached?
|
@@ -69,7 +69,7 @@ class Datagrid::Columns::Column
|
|
69
69
|
if options.has_key?(:order) && options[:order] != true
|
70
70
|
self.options[:order]
|
71
71
|
else
|
72
|
-
|
72
|
+
driver.default_order(grid_class.scope, name)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -107,8 +107,7 @@ class Datagrid::Columns::Column
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def enabled?(grid)
|
110
|
-
|
111
|
-
!column_availability(grid, options[:unless], false)
|
110
|
+
::Datagrid::Utils.process_availability(grid, options[:if], options[:unless])
|
112
111
|
end
|
113
112
|
|
114
113
|
def inspect
|
@@ -133,21 +132,36 @@ class Datagrid::Columns::Column
|
|
133
132
|
grid.generic_value(self, model)
|
134
133
|
end
|
135
134
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
135
|
+
def append_preload(scope)
|
136
|
+
return scope unless preload
|
137
|
+
if preload.respond_to?(:call)
|
138
|
+
return scope unless preload
|
139
|
+
if preload.arity == 1
|
140
|
+
preload.call(scope)
|
141
|
+
else
|
142
|
+
scope.instance_exec(&preload)
|
143
|
+
end
|
145
144
|
else
|
146
|
-
|
145
|
+
driver.default_preload(scope, preload)
|
147
146
|
end
|
148
147
|
end
|
149
148
|
|
149
|
+
def preload
|
150
|
+
preload = options[:preload]
|
151
|
+
|
152
|
+
if [nil, true].include?(preload) && driver.can_preload?(driver.to_scope(grid_class.scope), name)
|
153
|
+
name
|
154
|
+
else
|
155
|
+
preload
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
150
160
|
def callable(value)
|
151
161
|
value.respond_to?(:call) ? value.call : value
|
152
162
|
end
|
163
|
+
|
164
|
+
def driver
|
165
|
+
grid_class.driver
|
166
|
+
end
|
153
167
|
end
|
data/lib/datagrid/core.rb
CHANGED
@@ -35,7 +35,11 @@ module Datagrid
|
|
35
35
|
# Defines a scope at class level
|
36
36
|
def scope(&block)
|
37
37
|
if block
|
38
|
-
|
38
|
+
current_scope = scope_value
|
39
|
+
self.scope_value = proc {
|
40
|
+
Datagrid::Utils.apply_args(current_scope ? current_scope.call : nil, &block)
|
41
|
+
}
|
42
|
+
self
|
39
43
|
else
|
40
44
|
check_scope_defined!
|
41
45
|
scope_value.call
|
@@ -144,7 +148,12 @@ module Datagrid
|
|
144
148
|
|
145
149
|
# Resets current instance scope to default scope defined in a class
|
146
150
|
def reset_scope
|
147
|
-
|
151
|
+
self.scope_value = self.class.scope_value
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns true if the scope was redefined for this instance of grid object
|
155
|
+
def redefined_scope?
|
156
|
+
self.class.scope_value != scope_value
|
148
157
|
end
|
149
158
|
|
150
159
|
def driver #:nodoc:
|
@@ -105,6 +105,14 @@ module Datagrid
|
|
105
105
|
scope
|
106
106
|
end
|
107
107
|
|
108
|
+
def default_preload(scope, value)
|
109
|
+
raise NotImplementedError
|
110
|
+
end
|
111
|
+
|
112
|
+
def can_preload?(scope, association)
|
113
|
+
raise NotImplementedError
|
114
|
+
end
|
115
|
+
|
108
116
|
protected
|
109
117
|
def timestamp_class?(klass)
|
110
118
|
TIMESTAMP_CLASSES.include?(klass)
|
@@ -116,6 +116,14 @@ module Datagrid
|
|
116
116
|
asset.id || raise(NotImplementedError)
|
117
117
|
end
|
118
118
|
|
119
|
+
def default_preload(scope, value)
|
120
|
+
scope.preload(value)
|
121
|
+
end
|
122
|
+
|
123
|
+
def can_preload?(scope, association)
|
124
|
+
!! scope.klass.reflect_on_association(association)
|
125
|
+
end
|
126
|
+
|
119
127
|
protected
|
120
128
|
|
121
129
|
def prefix_table_name(scope, field)
|
@@ -94,6 +94,15 @@ module Datagrid
|
|
94
94
|
def default_cache_key(asset)
|
95
95
|
asset.id || raise(NotImplementedError)
|
96
96
|
end
|
97
|
+
|
98
|
+
def default_preload(scope, value)
|
99
|
+
scope.includes(value)
|
100
|
+
end
|
101
|
+
|
102
|
+
def can_preload?(scope, association)
|
103
|
+
!! scope.klass.reflect_on_association(association)
|
104
|
+
end
|
105
|
+
|
97
106
|
end
|
98
107
|
end
|
99
108
|
end
|