sortable-model 0.0.2 → 0.0.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/README.rdoc +29 -2
- data/VERSION +1 -1
- data/sortable-model.gemspec +58 -0
- metadata +2 -1
data/README.rdoc
CHANGED
@@ -1,6 +1,33 @@
|
|
1
1
|
= sortable-model
|
2
2
|
|
3
|
-
|
3
|
+
Sortable-model provides a DSL for creating named scopes that order the object in question based
|
4
|
+
on its own attributes or those of its associations. It also provides a method for calling those
|
5
|
+
scopes that allows the values to come directly from params without the risk of arbitrary code execution.
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
|
9
|
+
# Schema:
|
10
|
+
# Student: id (primary key), name (string), :major (string)
|
11
|
+
# Papers: id (primary key), student_id (int), title (string), grade (int)
|
12
|
+
|
13
|
+
class Student < ActiveRecord::Base
|
14
|
+
|
15
|
+
has_many :papers
|
16
|
+
|
17
|
+
sortable_model
|
18
|
+
|
19
|
+
can_sort_by :name
|
20
|
+
#=> student.sorted_by(:name) is students ordered by name DESC
|
21
|
+
#=> student.sorted_by(:name, true) is students ordered by name ASC
|
22
|
+
can_sort_by :grades, :papers => :grade
|
23
|
+
#=> student.sorted_by(:grades) is student ordered by the grades of her papers DESC
|
24
|
+
can_sort_by :something_complicated, lambda { |stdnt|
|
25
|
+
# some code that returns an order hash
|
26
|
+
}
|
27
|
+
#=> This one is really just a named scope that can use the sorted_by sanitizing method
|
28
|
+
end
|
29
|
+
|
30
|
+
The #sorted_by method takes either strings or symbols for the name of the sorter.
|
4
31
|
|
5
32
|
== Note on Patches/Pull Requests
|
6
33
|
|
@@ -14,4 +41,4 @@ Description goes here.
|
|
14
41
|
|
15
42
|
== Copyright
|
16
43
|
|
17
|
-
Copyright (c) 2010
|
44
|
+
Copyright (c) 2010 EdgeCase LLC. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sortable-model}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["EdgeCase LLC"]
|
12
|
+
s.date = %q{2010-02-03}
|
13
|
+
s.description = %q{Sortable-model provides a DSL for creating named scopes that order the object in question based
|
14
|
+
on its own attributes or those of its associations. It also provides a method for calling those
|
15
|
+
scopes that allows the values to come directly from params without the risk of arbitrary code execution.
|
16
|
+
}
|
17
|
+
s.email = %q{github@edgecase.com}
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".gitignore",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"lib/sortable-model.rb",
|
30
|
+
"sortable-model.gemspec",
|
31
|
+
"spec/sortable-model_spec.rb",
|
32
|
+
"spec/spec.opts",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/edgecase/sortable-model}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.5}
|
39
|
+
s.summary = %q{DSL for generating ordering named-scopes for ActiveRecord models}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/sortable-model_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sortable-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EdgeCase LLC
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- Rakefile
|
44
44
|
- VERSION
|
45
45
|
- lib/sortable-model.rb
|
46
|
+
- sortable-model.gemspec
|
46
47
|
- spec/sortable-model_spec.rb
|
47
48
|
- spec/spec.opts
|
48
49
|
- spec/spec_helper.rb
|