datagrid 0.7.0 → 0.7.1
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/VERSION +1 -1
- data/datagrid.gemspec +2 -2
- data/lib/datagrid/drivers/active_record.rb +11 -1
- data/spec/datagrid/drivers/active_record_spec.rb +6 -0
- data/spec/support/active_record.rb +1 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/datagrid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "datagrid"
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-15"
|
13
13
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
|
14
14
|
s.email = "agresso@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -12,7 +12,17 @@ module Datagrid
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_scope(scope)
|
15
|
-
|
15
|
+
# Model class or Active record association
|
16
|
+
# ActiveRecord association class hides itself under an Array
|
17
|
+
# We can only reveal it by checking if it respond to some specific
|
18
|
+
# to ActiveRecord method like #scoped
|
19
|
+
if scope.is_a?(Class)
|
20
|
+
scope.scoped({})
|
21
|
+
elsif (scope.is_a?(Array) && scope.respond_to?(:scoped))
|
22
|
+
scope.scoped
|
23
|
+
else
|
24
|
+
scope
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
def where(scope, condition)
|
@@ -9,5 +9,11 @@ describe Datagrid::Drivers::ActiveRecord do
|
|
9
9
|
it {should be_match(Entry.scoped)}
|
10
10
|
it {should_not be_match(MongoidEntry)}
|
11
11
|
end
|
12
|
+
|
13
|
+
it "should convert any scope to AR::Relation" do
|
14
|
+
subject.to_scope(Entry).should be_a(ActiveRecord::Relation)
|
15
|
+
subject.to_scope(Entry.limit(5)).should be_a(ActiveRecord::Relation)
|
16
|
+
subject.to_scope(Group.create!.entries).should be_a(ActiveRecord::Relation)
|
17
|
+
end
|
12
18
|
|
13
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -308,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
segments:
|
310
310
|
- 0
|
311
|
-
hash:
|
311
|
+
hash: -1867326624462415975
|
312
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
313
313
|
none: false
|
314
314
|
requirements:
|