trample_search 0.14.0 → 0.15.0

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: c648e258dedbc817af3e8fd1dd0e2beb759dbbda
4
- data.tar.gz: 92b492f65baf9d040f8b9a6616f109940441b53c
3
+ metadata.gz: b54a2b004d66cc10b02800ca0c760f68f1f9eacf
4
+ data.tar.gz: 3d6082f9e2ea2a5c84d68992313f10f91f299e23
5
5
  SHA512:
6
- metadata.gz: 6da88788dc47a9cf4749957aff836bfaadde11251b9a1b8d7d0bfac11129ac467f3252669a25f49e1c11a4ed5fe51a76004001869f9eb849a57e301ce05e1bb6
7
- data.tar.gz: 087289caefa82470f2d59501e2d40b0574a37bd5a2fd377446e7009d7f3fd9fc483c809151f01e54d871b91696d7a82ccf681710df9f370aaf6904fbc9085a21
6
+ metadata.gz: 5a0d96d4da55d0363a3d931e441d527c69024f058ae2326452ad8805e34aed2ceb3e072072822fc143e8267f40f77953f69529f0a7be50e3ffe0c8d7311069ee
7
+ data.tar.gz: 4d7a070c1b741f277b8f13ff60c96d79f997ca40a60cc377ca3251d6285d40972883ecf223b554b88be8931749f385b991e29cb1292499abacbcb6cb5f0070d2
data/README.md CHANGED
@@ -29,6 +29,18 @@ search.query!
29
29
  search.results
30
30
  ```
31
31
 
32
+ ## Install
33
+
34
+ ```bash
35
+ $ gem install trample_search
36
+ ```
37
+
38
+ or
39
+
40
+ ```ruby
41
+ gem 'trample_search'
42
+ ```
43
+
32
44
  ## Usage
33
45
 
34
46
  Check out the complete [documentation](http://richmolj.github.io/trample), or see usage in the [specs](https://github.com/richmolj/trample/blob/master/spec/integration/search_spec.rb).
@@ -19,6 +19,7 @@ module Trample
19
19
  attribute :range, Boolean, default: false
20
20
  attribute :fields, Array
21
21
  attribute :user_query, Hash
22
+ attribute :transform, Proc, default: ->(_,_) { ->(val) { val } }
22
23
 
23
24
  def initialize(attrs)
24
25
  attrs.merge!(single: true) if attrs[:name] == :keywords
@@ -190,14 +191,18 @@ module Trample
190
191
  end
191
192
 
192
193
  def to_range_query
194
+ _from_eq = transform.call(self.from_eq) if from_eq?
195
+ _to_eq = transform.call(self.to_eq) if to_eq?
196
+ _from = transform.call(self.from) if from?
197
+ _to = transform.call(self.to) if to?
198
+
193
199
  hash = {}
194
- hash.merge!(gte: from_eq) if from_eq?
195
- hash.merge!(gt: from) if from?
196
- hash.merge!(lte: to_eq) if to_eq?
197
- hash.merge!(lt: to) if to?
200
+ hash.merge!(gte: _from_eq) if _from_eq
201
+ hash.merge!(gt: _from) if _from
202
+ hash.merge!(lte: _to_eq) if _to_eq
203
+ hash.merge!(lt: _to) if _to
198
204
 
199
- {runtime_query_name => hash}
205
+ { runtime_query_name => hash }
200
206
  end
201
-
202
207
  end
203
208
  end
@@ -1,3 +1,3 @@
1
1
  module Trample
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trample_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - richmolj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus