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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid-data_table (1.0.0)
4
+ mongoid-data_table (1.0.1)
5
5
  rails (~> 3.0.0)
6
6
  will_paginate (~> 3.0.pre2)
7
7
 
@@ -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 = {}, explicit_block = nil, &implicit_block) #fields, search_fields=nil, explicit_block=nil, &implicit_block)
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, :block, :params, :criteria, :unscoped, :fields, :aliases
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
- @block = block
11
+ @extension = block
12
12
 
13
13
  @params = options[:params] || controller.params.dup
14
- @criteria = options[:criteria] || klass.scoped
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.clone.order_by(order_by_conditions).where(filter_conditions).where(filter_field_conditions)
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 = block || default_data_table_block unless block_given?
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[object] }
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))
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module DataTable
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
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.1
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-17 00:00:00 Z
14
+ date: 2011-05-18 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails