sortify 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sortify/version.rb +1 -1
- data/lib/sortify.rb +11 -30
- metadata +17 -4
- data/lib/tasks/sortify_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df249f71df3b88c2b0210fc0b961481774250ba
|
4
|
+
data.tar.gz: 7fb9003c06f0e087f639933b757b4bf844cb25e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 156757cef3993773cf418c62045fec29e1e7f87b29ef1eabc45b6e765ed7471e5a35e1f598edd1e9e7c6eec314ef8c458286f29dbab661abe4d1af5ce689fa7b
|
7
|
+
data.tar.gz: 5aed8e08a3fd22ab76c6cd8ea448122e11d725f96921818db6cbb4361e4e2543d6828c495cafb9b0315192d137e643a3cd42dfb1ae44660001395fef767dfafd
|
data/lib/sortify/version.rb
CHANGED
data/lib/sortify.rb
CHANGED
@@ -1,42 +1,23 @@
|
|
1
|
+
require 'whitelist_scope'
|
2
|
+
|
1
3
|
module Sortify
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
if self.respond_to?(name)
|
7
|
-
raise ArgumentError, "Could not create sort option, There is an existing method with this name."
|
8
|
-
end
|
9
|
-
|
10
|
-
begin
|
11
|
-
scope name, body
|
12
|
-
rescue ArgumentError => e
|
13
|
-
raise e
|
14
|
-
else
|
15
|
-
@sort_options << name
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
4
|
+
include WhitelistScope
|
5
|
+
alias_method :sort_option, :whitelist_scope
|
6
|
+
alias_method :sort_options, :whitelist
|
7
|
+
|
19
8
|
def default_sort_option(name)
|
20
9
|
@default_sort_option = name.to_sym
|
21
10
|
end
|
22
|
-
|
23
|
-
def sort_options
|
24
|
-
return @sort_options
|
25
|
-
end
|
26
11
|
|
27
|
-
def sortify(sort_option =
|
28
|
-
|
29
|
-
|
30
|
-
if @sort_options.include? sort_option
|
31
|
-
self.send(sort_option)
|
32
|
-
elsif sort_option.empty?
|
12
|
+
def sortify(sort_option = '')
|
13
|
+
if sort_option.empty?
|
33
14
|
begin
|
34
|
-
|
15
|
+
call_whitelisted_scope(@default_sort_option)
|
35
16
|
rescue
|
36
|
-
raise NoMethodError, "The default sort option you provided, '#{@default_sort_option
|
17
|
+
raise NoMethodError, "The default sort option you provided, '#{@default_sort_option}', does not exist."
|
37
18
|
end
|
38
19
|
else
|
39
|
-
|
20
|
+
call_whitelisted_scope(sort_option)
|
40
21
|
end
|
41
22
|
end
|
42
23
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sortify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: whitelist_scope
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sqlite3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +122,6 @@ files:
|
|
108
122
|
- Rakefile
|
109
123
|
- lib/sortify.rb
|
110
124
|
- lib/sortify/version.rb
|
111
|
-
- lib/tasks/sortify_tasks.rake
|
112
125
|
homepage: https://github.com/meltheadorable/sortify
|
113
126
|
licenses:
|
114
127
|
- MIT
|