aub-record_filter 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 9
4
- :patch: 10
4
+ :patch: 11
@@ -98,7 +98,7 @@ module RecordFilter
98
98
 
99
99
  module AssociationInstanceMethods
100
100
  def filter(&block)
101
- Filter.new(@reflection.klass, nil, &block)
101
+ Filter.new(self, @finder_sql, &block)
102
102
  end
103
103
  end
104
104
  end
@@ -10,11 +10,17 @@ module RecordFilter
10
10
  end
11
11
  end
12
12
 
13
- def initialize(clazz, named_filter, *args, &block) # :nodoc:
14
- @current_scoped_methods = clazz.send(:current_scoped_methods)
15
- @clazz = clazz
13
+ def initialize(clazz, filter, *args, &block) # :nodoc:
14
+ if clazz.is_a?(Class)
15
+ @current_scoped_methods = clazz.send(:current_scoped_methods)
16
+ @clazz = clazz
17
+ elsif clazz.is_a?(Array) && clazz.respond_to?(:proxy_reflection)
18
+ @current_scoped_methods = { :create => {}, :find => { :conditions => filter } }
19
+ @clazz = clazz.proxy_reflection.klass
20
+ filter = nil
21
+ end
16
22
 
17
- @query = Query.new(@clazz, named_filter, *args, &block)
23
+ @query = Query.new(@clazz, filter, *args, &block)
18
24
  end
19
25
 
20
26
  def first(*args) # :nodoc:
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{record_filter}
5
- s.version = "0.9.10"
5
+ s.version = "0.9.11"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Aubrey Holland", "Mat Brown"]
9
- s.date = %q{2009-08-09}
9
+ s.date = %q{2009-08-11}
10
10
  s.description = %q{RecordFilter is a Pure-ruby criteria API for building complex queries in ActiveRecord. It supports queries that are built on the fly as well as named filters that can be added to objects and chained to create complex queries. It also gets rid of the nasty hard-coded SQL that shows up in most ActiveRecord code with a clean API that makes queries simple and intuitive to build.}
11
11
  s.email = %q{aubreyholland@gmail.com}
12
12
  s.extra_rdoc_files = [
@@ -69,7 +69,7 @@ Gem::Specification.new do |s|
69
69
  s.homepage = %q{http://github.com/aub/record_filter/tree/master}
70
70
  s.rdoc_options = ["--charset=UTF-8"]
71
71
  s.require_paths = ["lib"]
72
- s.rubygems_version = %q{1.3.5}
72
+ s.rubygems_version = %q{1.3.3}
73
73
  s.summary = %q{An ActiveRecord query API for replacing SQL with awesome}
74
74
  s.test_files = [
75
75
  "spec/active_record_spec.rb",
@@ -242,9 +242,10 @@ describe 'RecordFilter restrictions' do
242
242
  end
243
243
 
244
244
  it 'should properly filter when filter is applied to an association' do
245
+ Post.create
245
246
  Post.first.comments.filter do
246
247
  with(:offensive, true)
247
248
  end.inspect
248
- Comment.last_find.should == { :readonly => false, :conditions => [%q("comments".offensive = ?), true] }
249
+ Comment.last_find.should == { :readonly => false, :conditions => "(\"comments\".offensive = 't') AND (\"comments\".post_id = #{Post.first.id})" }
249
250
  end
250
251
  end
data/spec/test.db CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aub-record_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aubrey Holland
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-08-09 00:00:00 -07:00
13
+ date: 2009-08-11 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16