aub-record_filter 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/lib/record_filter/active_record.rb +1 -1
- data/lib/record_filter/dsl/dsl_factory.rb +2 -2
- data/lib/record_filter/query.rb +4 -2
- data/spec/spec_helper.rb +6 -1
- data/spec/test.db +0 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -142,6 +142,8 @@ The following condition types are supported through the Restriction API:
|
|
142
142
|
* Is null
|
143
143
|
* Like
|
144
144
|
|
145
|
+
See the RDoc page for {DSL::Restriction}[http://aub.github.com/record_filter/rdoc/classes/RecordFilter/DSL/Restriction.html] for specifics on how to use these.
|
146
|
+
|
145
147
|
=== Boolean Operations
|
146
148
|
|
147
149
|
Conditions can be combined with boolean operators using the methods all_of, any_of, none_of
|
data/Rakefile
CHANGED
@@ -12,10 +12,10 @@ begin
|
|
12
12
|
require 'jeweler'
|
13
13
|
Jeweler::Tasks.new do |gemspec|
|
14
14
|
gemspec.name = 'record_filter'
|
15
|
-
gemspec.summary = '
|
15
|
+
gemspec.summary = 'An ActiveRecord query API for replacing SQL with awesome'
|
16
16
|
gemspec.email = 'aubreyholland@gmail.com'
|
17
17
|
gemspec.homepage = 'http://github.com/aub/record_filter/tree/master'
|
18
|
-
gemspec.description = 'Pure-ruby criteria API for building complex queries in ActiveRecord'
|
18
|
+
gemspec.description = '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.'
|
19
19
|
gemspec.authors = ['Aubrey Holland', 'Mat Brown']
|
20
20
|
end
|
21
21
|
rescue LoadError
|
data/VERSION.yml
CHANGED
@@ -63,7 +63,7 @@ module RecordFilter
|
|
63
63
|
raise InvalidFilterNameException.new("A named filter with the name #{name} already exists on the class #{self.name}.")
|
64
64
|
end
|
65
65
|
local_named_filters << name.to_sym
|
66
|
-
DSL::DSLFactory::
|
66
|
+
DSL::DSLFactory::get_subclass(self).module_eval do
|
67
67
|
define_method(name, &block)
|
68
68
|
end
|
69
69
|
|
@@ -7,10 +7,10 @@ module RecordFilter
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def create(clazz)
|
10
|
-
|
10
|
+
get_subclass(clazz).new(clazz, Conjunction.new(clazz, :all_of))
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def get_subclass(clazz)
|
14
14
|
SUBCLASSES[clazz.object_id]
|
15
15
|
end
|
16
16
|
end
|
data/lib/record_filter/query.rb
CHANGED
@@ -44,8 +44,10 @@ module RecordFilter
|
|
44
44
|
def dsl_for_named_filter(clazz, named_filter)
|
45
45
|
return DSL::DSLFactory.create(clazz) if named_filter.blank?
|
46
46
|
while (clazz)
|
47
|
-
dsl = DSL::DSLFactory.
|
48
|
-
|
47
|
+
dsl = DSL::DSLFactory.get_subclass(clazz)
|
48
|
+
if dsl && dsl.instance_methods(false).map { |m| m.to_sym }.include?(named_filter.to_sym)
|
49
|
+
return DSL::DSLFactory.create(clazz)
|
50
|
+
end
|
49
51
|
clazz = clazz.superclass
|
50
52
|
end
|
51
53
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,12 @@ require 'rubygems'
|
|
2
2
|
gem 'rspec', '~> 1.1'
|
3
3
|
gem 'sqlite3-ruby'
|
4
4
|
|
5
|
-
|
5
|
+
begin
|
6
|
+
require 'ruby-debug'
|
7
|
+
rescue LoadError
|
8
|
+
puts 'ruby-debug is not available. Good luck debugging'
|
9
|
+
end
|
10
|
+
|
6
11
|
require 'spec'
|
7
12
|
|
8
13
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'record_filter')
|
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.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aubrey Holland
|
@@ -10,11 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-05-
|
13
|
+
date: 2009-05-07 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
17
|
-
description: Pure-ruby criteria API for building complex queries in ActiveRecord
|
17
|
+
description: 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.
|
18
18
|
email: aubreyholland@gmail.com
|
19
19
|
executables: []
|
20
20
|
|
@@ -89,7 +89,7 @@ rubyforge_project:
|
|
89
89
|
rubygems_version: 1.2.0
|
90
90
|
signing_key:
|
91
91
|
specification_version: 3
|
92
|
-
summary:
|
92
|
+
summary: An ActiveRecord query API for replacing SQL with awesome
|
93
93
|
test_files:
|
94
94
|
- spec/active_record_spec.rb
|
95
95
|
- spec/exception_spec.rb
|