filterameter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/filterameter/filter_registry.rb +5 -4
- data/lib/filterameter/query_builder.rb +10 -2
- data/lib/filterameter/version.rb +1 -1
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5ff39d6e3e772f3943678ecc748ca3f9d9234417958fc9254071ee14764ed31
|
4
|
+
data.tar.gz: 22e0d442436d0cae884e60a60066eea859c7de22251d6471e05c289af50f3da1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67cd4b48cf4f50e0681e34003f0f9ebe7ae753b703f83121d017daaee7185c846c4e2e467d2b140fc14ced8e11b07f88b155a1dda4b6e0a9104906348f077a53
|
7
|
+
data.tar.gz: f80c40fcd3a438682bd95c7b3c282dae7cc199c57375372314d0720c234c53aa0b4609c47cccc2dcb85505a023f74e9ba6c6e2125714a5d48710c87bff20a6d5
|
@@ -16,13 +16,14 @@ module Filterameter
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def add_filter(parameter_name, options)
|
19
|
-
|
20
|
-
|
19
|
+
name = parameter_name.to_s
|
20
|
+
@declarations[name] = Filterameter::FilterDeclaration.new(name, options).tap do |fd|
|
21
|
+
add_declarations_for_range(fd, options, name) if fd.range_enabled?
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
def fetch(
|
25
|
-
name =
|
25
|
+
def fetch(parameter_name)
|
26
|
+
name = parameter_name.to_s
|
26
27
|
@filters.fetch(name) do
|
27
28
|
raise Filterameter::Exceptions::UndeclaredParameterError, name unless @declarations.keys.include?(name)
|
28
29
|
|
@@ -11,7 +11,7 @@ module Filterameter
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def build_query(filter_params, starting_query = nil)
|
14
|
-
valid_filters(filter_params)
|
14
|
+
valid_filters(filter_params.stringify_keys)
|
15
15
|
.tap { |parameters| convert_min_and_max_to_range(parameters) }
|
16
16
|
.reduce(starting_query || @default_query) do |query, (name, value)|
|
17
17
|
add_filter_parameter_to_query(query, name, value)
|
@@ -64,7 +64,15 @@ module Filterameter
|
|
64
64
|
raise Filterameter::Exceptions::ValidationError, validator.errors
|
65
65
|
end
|
66
66
|
|
67
|
-
filter_params.except(*validator.errors.
|
67
|
+
filter_params.except(*invalid_attributes(validator.errors).map(&:to_s))
|
68
|
+
end
|
69
|
+
|
70
|
+
def invalid_attributes(errors)
|
71
|
+
if errors.respond_to? :attribute_names
|
72
|
+
errors.attribute_names
|
73
|
+
else # pre rails 6.1
|
74
|
+
errors.keys
|
75
|
+
end
|
68
76
|
end
|
69
77
|
|
70
78
|
def validator_class
|
data/lib/filterameter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filterameter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Kummer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.4.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.4.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: guard
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +114,28 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
117
|
+
version: 1.31.1
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
124
|
+
version: 1.31.1
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rubocop-rails
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
131
|
+
version: 2.15.1
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.
|
138
|
+
version: 2.15.1
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: simplecov
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +150,7 @@ dependencies:
|
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0.18'
|
139
|
-
description: Enable filter parameters to be declared in controllers.
|
153
|
+
description: Enable filter parameters to be declared in query classes or controllers.
|
140
154
|
email:
|
141
155
|
- todd@rockridgesolutions.com
|
142
156
|
executables: []
|
@@ -194,8 +208,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
208
|
- !ruby/object:Gem::Version
|
195
209
|
version: '0'
|
196
210
|
requirements: []
|
197
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.1.6
|
198
212
|
signing_key:
|
199
213
|
specification_version: 4
|
200
|
-
summary: Declarative Filter Parameters
|
214
|
+
summary: Declarative Filter Parameters
|
201
215
|
test_files: []
|