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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c7e8fda93afabd994bb1fe333e3990f67c3d97c
4
- data.tar.gz: da621d1465961fdbfc44de10e9f7f2a704e0be51
3
+ metadata.gz: 8df249f71df3b88c2b0210fc0b961481774250ba
4
+ data.tar.gz: 7fb9003c06f0e087f639933b757b4bf844cb25e3
5
5
  SHA512:
6
- metadata.gz: 3b2cf8b1297aba8632f99c9d40a258d2f4ec2b267c0be2a3f823d59de5ff6010587a037c849ed51e4d0eaa71ffbc9f0caf7a9f12be0494d7ac4bf8d3757890e1
7
- data.tar.gz: ee7f11f95a40a4eef8db3ef98f9277597f2214aabd362c633bfbc57055c4a7e1420199d208c534d2aab101bf3a94cb82174fc9e45280ee70a1782893f92a1a68
6
+ metadata.gz: 156757cef3993773cf418c62045fec29e1e7f87b29ef1eabc45b6e765ed7471e5a35e1f598edd1e9e7c6eec314ef8c458286f29dbab661abe4d1af5ce689fa7b
7
+ data.tar.gz: 5aed8e08a3fd22ab76c6cd8ea448122e11d725f96921818db6cbb4361e4e2543d6828c495cafb9b0315192d137e643a3cd42dfb1ae44660001395fef767dfafd
@@ -1,3 +1,3 @@
1
1
  module Sortify
2
- VERSION = "0.1.6"
2
+ VERSION = '0.1.7'
3
3
  end
data/lib/sortify.rb CHANGED
@@ -1,42 +1,23 @@
1
+ require 'whitelist_scope'
2
+
1
3
  module Sortify
2
- def sort_option(name, body)
3
- @sort_options ||= []
4
- name = name.to_sym
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
- sort_option = sort_option.to_sym unless sort_option == nil
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
- self.send(@default_sort_option)
15
+ call_whitelisted_scope(@default_sort_option)
35
16
  rescue
36
- raise NoMethodError, "The default sort option you provided, '#{@default_sort_option.to_s}', does not exist."
17
+ raise NoMethodError, "The default sort option you provided, '#{@default_sort_option}', does not exist."
37
18
  end
38
19
  else
39
- raise NoMethodError, "The sort option you provided, '#{sort_option}', does not exist."
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.6
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-23 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
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
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :sortify do
3
- # # Task goes here
4
- # end