mongoid-data_table 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/mongoid/data_table.rb +1 -3
- data/lib/mongoid/data_table/proxy.rb +6 -6
- data/lib/mongoid/data_table/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/mongoid/data_table.rb
CHANGED
@@ -35,9 +35,7 @@ module Mongoid
|
|
35
35
|
self.data_table_options[:sortable] ||= self.data_table_fields
|
36
36
|
end
|
37
37
|
|
38
|
-
def to_data_table(controller, options = {},
|
39
|
-
block = (explicit_block or implicit_block)
|
40
|
-
|
38
|
+
def to_data_table(controller, options = {}, &block)
|
41
39
|
::Mongoid::DataTable::Proxy.new(self, controller, options, &block)
|
42
40
|
end
|
43
41
|
|
@@ -2,16 +2,16 @@ module Mongoid
|
|
2
2
|
module DataTable
|
3
3
|
class Proxy < ::Mongoid::Relations::Proxy
|
4
4
|
|
5
|
-
attr_reader :klass, :controller, :options, :
|
5
|
+
attr_reader :klass, :controller, :options, :extension, :params, :criteria, :unscoped, :fields, :aliases
|
6
6
|
|
7
7
|
def initialize(klass, controller, options = {}, &block)
|
8
8
|
@klass = klass
|
9
9
|
@controller = controller
|
10
10
|
@options = klass.data_table_options.merge(options)
|
11
|
-
@
|
11
|
+
@extension = block
|
12
12
|
|
13
13
|
@params = options[:params] || controller.params.dup
|
14
|
-
@criteria = options[:criteria] || klass.
|
14
|
+
@criteria = options[:criteria] || klass.criteria
|
15
15
|
@unscoped = options[:unscoped] || klass.unscoped
|
16
16
|
@fields = options[:fields] || klass.data_table_fields
|
17
17
|
@aliases = options[:aliases] || @fields
|
@@ -40,17 +40,17 @@ module Mongoid
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def conditions
|
43
|
-
criteria.
|
43
|
+
criteria.order_by(order_by_conditions).where(filter_conditions).where(filter_field_conditions)
|
44
44
|
end
|
45
45
|
|
46
46
|
def to_hash(&inline_block)
|
47
|
-
inline_block =
|
47
|
+
inline_block = extension || default_data_table_block unless block_given?
|
48
48
|
{
|
49
49
|
:sEcho => params[:sEcho].to_i,
|
50
50
|
:iTotalRecords => unscoped.count,
|
51
51
|
:iTotalDisplayRecords => conditions.count,
|
52
52
|
:aaData => collection.map do |object|
|
53
|
-
data = controller.instance_eval { inline_block
|
53
|
+
data = controller.instance_eval { inline_block.call(object) }
|
54
54
|
data.inject(data.is_a?(Hash) ? {} : []) do |result, item|
|
55
55
|
Rails.logger.silence do
|
56
56
|
controller.instance_eval(&render_data_table_block(klass, item, object, result))
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mongoid-data_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jason Dew
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05-
|
14
|
+
date: 2011-05-18 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|