rails-tables 0.2.2 → 0.2.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/app/tables/datatable.rb +7 -7
- data/lib/rails-tables/version.rb +1 -1
- metadata +2 -3
data/app/tables/datatable.rb
CHANGED
@@ -7,11 +7,11 @@ attr_accessor :name, :model
|
|
7
7
|
self.model = model
|
8
8
|
end
|
9
9
|
|
10
|
-
attr_accessor :view, :
|
10
|
+
attr_accessor :view, :scopes
|
11
11
|
def render_with(view, *args)
|
12
12
|
arguments = args.pop || {}
|
13
13
|
self.view = view
|
14
|
-
self.
|
14
|
+
self.scopes = arguments.fetch(:scopes, {})
|
15
15
|
return self
|
16
16
|
end
|
17
17
|
|
@@ -24,7 +24,7 @@ attr_accessor :view, :filters
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
-
class_attribute :columns, :searches, :
|
27
|
+
class_attribute :columns, :searches, :authorized_scopes, :match_any
|
28
28
|
def self.column(name, *args)
|
29
29
|
arguments = args.pop || {}
|
30
30
|
self.columns = [] if self.columns.nil?
|
@@ -36,8 +36,8 @@ class_attribute :columns, :searches, :scopes, :match_any
|
|
36
36
|
self.searches << Search.new(name, self, arguments)
|
37
37
|
end
|
38
38
|
def self.available_scopes(*args)
|
39
|
-
self.
|
40
|
-
self.
|
39
|
+
self.authorized_scopes = [] if self.authorized_scopes.nil?
|
40
|
+
self.authorized_scopes += args
|
41
41
|
end
|
42
42
|
def self.match_any_column(match_any=true)
|
43
43
|
self.match_any = true if self.match_any.nil?
|
@@ -52,8 +52,8 @@ private
|
|
52
52
|
else
|
53
53
|
objects = self.model
|
54
54
|
end
|
55
|
-
self.
|
56
|
-
objects = objects.send(method, *arguments) if self.
|
55
|
+
self.scopes.each do |method, arguments|
|
56
|
+
objects = objects.send(method, *arguments) if self.authorized_scopes.include?(method.to_sym)
|
57
57
|
end
|
58
58
|
if params[:sSearch].present?
|
59
59
|
objects = objects.send("#{self.name}_search", params[:sSearch])
|
data/lib/rails-tables/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,8 +75,7 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.0.11
|
78
|
-
description: A clean jQuery datatables DSL
|
79
|
-
jQuery datatables railscast.
|
78
|
+
description: A clean jQuery datatables DSL.
|
80
79
|
email:
|
81
80
|
- dev@chriskeele.com
|
82
81
|
executables: []
|