refiner 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/refiner.rb +5 -4
- data/lib/refiner/query.rb +18 -0
- data/lib/refiner/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f496805ed02d5b66672b287208020df4e1a2999
|
4
|
+
data.tar.gz: 4e5fceaccac55662bb661604ad4f5a16f897b3c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab2b31ca35cade30df4efc425f5a4a41aeb1a4e149bc1e9c2cdc2f57cb13d955e0ca87b5dcf756a383dc0cb1ec584adda28b9cec8a1a79d5d9580888493f152c
|
7
|
+
data.tar.gz: f873858a0365acb9c2f64c7ce7eabe565c07beae3098b18671b9fb6589c184a0a326068a59179ce9f8981ec5d141ed873600e9911db04d1ee407d60a3250dbd6
|
data/lib/refiner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "rails"
|
2
|
+
require "refiner/query"
|
2
3
|
require "refiner/version"
|
3
4
|
|
4
5
|
module Refiner
|
@@ -16,11 +17,11 @@ module Refiner
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def refiner_active? scope, slug
|
19
|
-
(
|
20
|
+
(refiner_query[scope.to_s] || "").split(/,/).include?(slug.to_s) ? 'active' : nil
|
20
21
|
end
|
21
22
|
|
22
23
|
def refiner_value action, scope, slug
|
23
|
-
REFINER_VALUE[refiner_value_selector(action, scope, slug)].call(
|
24
|
+
REFINER_VALUE[refiner_value_selector(action, scope, slug)].call(refiner_query, scope, slug)
|
24
25
|
end
|
25
26
|
|
26
27
|
def refiner_value_selector action, scope, slug
|
@@ -30,9 +31,9 @@ module Refiner
|
|
30
31
|
def refiners action, scope, slug
|
31
32
|
merge_values = refiner_value action, scope, slug
|
32
33
|
if merge_values.present?
|
33
|
-
|
34
|
+
refiner_query.merge({ scope => merge_values })
|
34
35
|
else
|
35
|
-
|
36
|
+
refiner_query.delete_if { |k, v| k == scope }
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Refiner
|
2
|
+
module Query
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
helper_method :refiner_query
|
7
|
+
helper_method :segment_refiner_query_by
|
8
|
+
end
|
9
|
+
|
10
|
+
def segment_refiner_query_by(*detectors)
|
11
|
+
refiner_query.slice(*detectors) rescue {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def refiner_query
|
15
|
+
Hash[*params[:query].split(/\//)] rescue {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/refiner/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Siri
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- bin/console
|
55
55
|
- bin/setup
|
56
56
|
- lib/refiner.rb
|
57
|
+
- lib/refiner/query.rb
|
57
58
|
- lib/refiner/version.rb
|
58
59
|
- refiner.gemspec
|
59
60
|
homepage: http://github.com/zacksiri/refiner
|