elastic_record 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.7.3'
5
+ s.version = '0.8.0'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -11,5 +11,18 @@ module ElasticRecord
11
11
  end
12
12
  end
13
13
  end
14
+
15
+ def as_search
16
+ json = {}
17
+ elastic_index.mapping[:properties].each_key do |key|
18
+ if respond_to?(key) && (value = send(key)).present?
19
+ json[key] = value
20
+ end
21
+ end
22
+
23
+ amend_as_search(json) if respond_to?(:amend_as_search)
24
+
25
+ json
26
+ end
14
27
  end
15
28
  end
@@ -25,4 +25,14 @@ class ElasticRecord::CallbacksTest < MiniTest::Spec
25
25
 
26
26
  refute Widget.elastic_index.record_exists?(widget.id)
27
27
  end
28
+
29
+ def test_as_search
30
+ Widget.new(id: '10', color: 'green').tap do |widget|
31
+ assert_equal({color: "green"}, widget.as_search)
32
+ end
33
+
34
+ Widget.new(id: '10', color: '').tap do |widget|
35
+ assert_equal({}, widget.as_search)
36
+ end
37
+ end
28
38
  end
@@ -214,4 +214,4 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
214
214
  def relation
215
215
  @relation ||= Widget.elastic_relation
216
216
  end
217
- end
217
+ end
@@ -45,8 +45,4 @@ class Widget
45
45
  send("#{key}=", val)
46
46
  end
47
47
  end
48
-
49
- def as_search
50
- {name: name, color: color}
51
- end
52
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-05 00:00:00.000000000 Z
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic
16
- requirement: &70305939301120 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70305939301120
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: activemodel
27
- requirement: &70305939300660 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70305939300660
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: Find your records with elastic search
37
47
  email: developer@matthewhiggins.com
38
48
  executables: []
@@ -112,9 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
122
  version: 1.8.11
113
123
  requirements: []
114
124
  rubyforge_project:
115
- rubygems_version: 1.8.17
125
+ rubygems_version: 1.8.24
116
126
  signing_key:
117
127
  specification_version: 3
118
128
  summary: Use Elastic Search with your objects
119
129
  test_files: []
120
- has_rdoc: