datagrid 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "datagrid"
8
- s.version = "0.7.0"
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 = "2012-12-15"
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
- scope.scoped({})
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
@@ -32,5 +32,6 @@ ActiveRecord::Schema.define(:version => 1) do
32
32
  belongs_to :group
33
33
  end
34
34
  class ::Group < ActiveRecord::Base
35
+ has_many :entries
35
36
  end
36
37
  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.0
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: 2012-12-15 00:00:00.000000000 Z
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: 813907041614063922
311
+ hash: -1867326624462415975
312
312
  required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  none: false
314
314
  requirements: