gyroscope 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +15 -0
- data/lib/gyroscope/search_base.rb +17 -1
- data/lib/gyroscope/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 921456f0511457b6ac95020900184bbd72dda476
|
4
|
+
data.tar.gz: 58b80e30d3121376dc532814056305217c8fa6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15335b433d70c5b3c3854269f7e3ad4f449d7b92164684572ac064478bde20812432b678b43847225fce13ce2d6127620868197b26939d605ae307d5c6bbd90f
|
7
|
+
data.tar.gz: 4e63ef51e2f8e1f302190215b71cb85f008ff7713cac02ffab9a19b016677baa8f4d6f5bea987e96312af5eba7d63a8cfb38c966cfdb28eb748f25046f27a763
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
CHANGELOG inspiration from http://keepachangelog.com/.
|
5
|
+
|
6
|
+
## Unreleased
|
7
|
+
|
8
|
+
## [0.1.1] - April 18, 2016
|
9
|
+
* Raise an error that has the errors object so we can render it nicely.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,22 @@ Or install it yourself as:
|
|
22
22
|
```ruby
|
23
23
|
module Search
|
24
24
|
class User < Gyroscope::SearchBase
|
25
|
+
attribute :ids, Gyroscope::IntegerList
|
25
26
|
attribute :name, String
|
27
|
+
|
28
|
+
def build_search_scope
|
29
|
+
scope = super
|
30
|
+
|
31
|
+
if ids.present?
|
32
|
+
scope = scope.where(id: ids)
|
33
|
+
end
|
34
|
+
|
35
|
+
if name.present?
|
36
|
+
scope = scope.where(name: name)
|
37
|
+
end
|
38
|
+
|
39
|
+
scope
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
|
@@ -21,12 +21,28 @@ module Gyroscope
|
|
21
21
|
"::#{self.class.name.demodulize}".constantize
|
22
22
|
end
|
23
23
|
|
24
|
+
class ValidationError < StandardError
|
25
|
+
attr_reader :searcher
|
26
|
+
|
27
|
+
def initialize(searcher)
|
28
|
+
@searcher = searcher
|
29
|
+
end
|
30
|
+
|
31
|
+
def message
|
32
|
+
"Check your default values for correctness"
|
33
|
+
end
|
34
|
+
|
35
|
+
def as_json(*)
|
36
|
+
{ errors: searcher.errors }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
24
40
|
def search
|
25
41
|
# is there a more generic ActiveModel validation error?
|
26
42
|
unless valid?
|
27
43
|
Rails.logger.debug("the errors: #{errors.inspect}")
|
28
44
|
end
|
29
|
-
fail
|
45
|
+
fail ValidationError.new(self) unless valid?
|
30
46
|
|
31
47
|
build_search_scope
|
32
48
|
end
|
data/lib/gyroscope/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyroscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wilhelm
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".gitignore"
|
121
121
|
- ".rspec"
|
122
122
|
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|