elasticsearch-rails-dynamic-json-support 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -18
- data/VERSION +1 -1
- data/elasticsearch-rails-dynamic-json-support.gemspec +3 -3
- data/lib/elasticsearch/model/cascade_update.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e92105a25788097c08f205783d49a2ca4ffc488d
|
4
|
+
data.tar.gz: 27ad97de60bfef4b595e836913799ebf5eba7592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1de5aa05408a2f2bb3fc5d5a56669d77a24bb72a35a19c727d4390965e816b88694f62045fc7e1f12cf10eb19aac5061ad0e9af7405fefc138283a269f1704e4
|
7
|
+
data.tar.gz: 2c1ed2db427152286624d55d020c227f4175fe72fa9ab2f07c6f070052c88740a57e0d2905642e3a467b2a12525da886558944818c96e1a7f695ab7e3cb27426
|
data/README.md
CHANGED
@@ -97,25 +97,25 @@ Example usage (which solves the 2 issues above) is as given below:
|
|
97
97
|
end
|
98
98
|
```
|
99
99
|
|
100
|
-
#
|
100
|
+
# ToDos
|
101
101
|
|
102
|
-
- Tests.. since I don't have time to write test case for this project yet.
|
103
|
-
- Due to the `lazy-loading` of model in rails, you need to specifically
|
104
|
-
the model in rails. Like in the `Review` class above, it's reference
|
105
|
-
`Article`
|
102
|
+
- [ ] Tests.. since I don't have time to write test case for this project yet.
|
103
|
+
- [ ] Due to the `lazy-loading` of model in rails, you need to specifically
|
104
|
+
specify the model in rails. Like in the `Review` class above, it's reference
|
105
|
+
to `Article` (to make sure that `Article` class is loaded before `Review`)
|
106
|
+
- [ ] Auto generation of mapping
|
106
107
|
|
107
|
-
|
108
|
+
# Contributing to elasticsearch-rails-dynamic-json-support
|
108
109
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
Copyright (c) 2016 Song Yangyu. See LICENSE.txt for
|
120
|
-
further details.
|
110
|
+
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
111
|
+
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
112
|
+
- Fork the project.
|
113
|
+
- Start a feature/bugfix branch.
|
114
|
+
- Commit and push until you are happy with your contribution.
|
115
|
+
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
116
|
+
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
117
|
+
|
118
|
+
# Copyright
|
119
|
+
|
120
|
+
Copyright (c) 2016 Song Yangyu. See LICENSE.txt for further details.
|
121
121
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: elasticsearch-rails-dynamic-json-support 0.0.
|
5
|
+
# stub: elasticsearch-rails-dynamic-json-support 0.0.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "elasticsearch-rails-dynamic-json-support".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Song Yangyu".freeze]
|
14
|
-
s.date = "2016-08-
|
14
|
+
s.date = "2016-08-31"
|
15
15
|
s.description = "Enhance elasticsearch-rails with `elasticsearch_json_changes` to translate the attribute changes into document updates".freeze
|
16
16
|
s.email = "flyfy1@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -41,7 +41,7 @@ module Elasticsearch
|
|
41
41
|
class_methods do
|
42
42
|
|
43
43
|
# attributes is a pair of <key, block>
|
44
|
-
def
|
44
|
+
def es_register_attrs *attributes
|
45
45
|
hashed_attributes = attributes.extract_options!
|
46
46
|
|
47
47
|
attributes.each do |k|
|
@@ -59,6 +59,9 @@ module Elasticsearch
|
|
59
59
|
key_name = key_name.to_s
|
60
60
|
return json_relationship_registry[key_name] unless blk
|
61
61
|
|
62
|
+
# If key_name has been defined, then fail fast
|
63
|
+
fail "json key_name has been already defined: #{key_name} for class #{self.name}" if json_relationship_registry[key_name]
|
64
|
+
|
62
65
|
relationship_name = key_name unless relationship_name
|
63
66
|
relationship_name = relationship_name.to_s
|
64
67
|
|
@@ -87,11 +90,19 @@ module Elasticsearch
|
|
87
90
|
|
88
91
|
def to_indexed_json(record, options = {})
|
89
92
|
result = {}
|
93
|
+
exclude_keys = options[:exclude_keys]
|
94
|
+
exclude_keys = [] unless exclude_keys
|
95
|
+
exclude_keys = exclude_keys.map(&:to_s)
|
96
|
+
|
90
97
|
json_attribute_registry.each do |k, blk|
|
98
|
+
k = k.to_s
|
99
|
+
next if exclude_keys.include? k
|
91
100
|
result[k] = blk[record]
|
92
101
|
end
|
93
102
|
|
94
103
|
json_relationship_registry.each do |k, actor|
|
104
|
+
k = k.to_s
|
105
|
+
next if exclude_keys.include? k
|
95
106
|
result[k] = actor.to_json(record)
|
96
107
|
end
|
97
108
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails-dynamic-json-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Song Yangyu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch-rails
|