elos 1.0.23 → 1.0.24

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: 141f44ad81bf0ce324ac8918170dd06db0df709b
4
- data.tar.gz: ce57df759708da43d8055905e3bd7c7d106b846c
3
+ metadata.gz: 80382b0017ffa0a395fe35b6de528b0339ec8d27
4
+ data.tar.gz: cdddbe3449d25388913a6b2561ae82ea351f835c
5
5
  SHA512:
6
- metadata.gz: 03c23fba73664c3facd81d9808da21292e4a35baadcbffb242591372f2ecfd703d8f7280864d06d3a50281f141526611e2928f65a5818e825e10e4785a2e3f5b
7
- data.tar.gz: 423bd408370fca519eb2e67bcf438491a03ced41a6df7c5b90171203ab987f1955b9315f0164e97478dd3dcdb9d600c413c5019bc5e66969348765db4df4be5f
6
+ metadata.gz: a3cfc4e04e08d71f0b38692e4a43ebab7e0546cf14a0eaf1be58348e3497d5d09b4e77a2d4d180dc03cbe4a93b0fc2cd711a183e42961aa9ff70746fc9ad39eb
7
+ data.tar.gz: a66163a35fc1b7127a23e49dc42c0571b249bf8ac1fd3cce6c42c5c116219a9e15c6a3c25c7cfa90f43c60c8ad5f3b0217443d2df8ad0bd4539678e6d28d4e8e
@@ -0,0 +1,5 @@
1
+ class Elos::Index::Attributes::KeysGuesser
2
+ def self.guess(given_mappings, mappings_fields)
3
+ %i(id) + (given_mappings.try(:[], :properties) || {}).merge(mappings_fields || {}).keys
4
+ end
5
+ end
@@ -2,6 +2,12 @@ module Elos::Index::Attributes
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- cattr_accessor :attribute_keys
5
+ cattr_accessor :set_attribute_keys
6
+ end
7
+
8
+ class_methods do
9
+ def attribute_keys
10
+ self.set_attribute_keys ||= KeysGuesser.guess(given_mappings, mappings_fields)
11
+ end
6
12
  end
7
13
  end
@@ -0,0 +1,14 @@
1
+ class Elos::Index::Mappings::Generator
2
+ include Elos::Index::Properties
3
+
4
+ def self.generate(mappings, fields:, physically_destroyable:, type_name:)
5
+ fields ||= {}
6
+ mappings = (mappings || {}).deep_dup
7
+ mappings[:_all] = { enabled: false } unless mappings[:_all]
8
+ properties = mappings[:properties] || {}
9
+ properties[:_destroyed] = boolean_property unless physically_destroyable
10
+ properties[:json] = no_index_string_property
11
+ properties.reverse_merge!(fields)
12
+ { type_name => mappings }
13
+ end
14
+ end
@@ -2,25 +2,18 @@ module Elos::Index::Mappings
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- cattr_writer :mappings
5
+ cattr_accessor :given_mappings, :set_mappings, :mappings_fields
6
6
  end
7
7
 
8
8
  class_methods do
9
- def mappings(mappings = nil)
10
- if mappings
11
- set_mappings(mappings)
12
- else
13
- self.class_variable_get(:@@mappings)
14
- end
9
+ def field(name, type)
10
+ self.mappings_fields ||= {}
11
+ mappings_fields[name] = send("#{type}_property")
15
12
  end
16
13
 
17
- protected
18
-
19
- def set_mappings(mappings)
20
- mps = mappings.is_a?(Proc) ? mappings.() : mappings.deep_dup
21
- self.attribute_keys = %i(id) + mps[:properties].keys
22
- mps[:properties].merge!(_destroyed: boolean_property, json: no_index_string_property) if respond_to?(:physically_destroy?) && physically_destroy?
23
- self.mappings = { type_name => mps }
14
+ def mappings(mappings = nil)
15
+ return self.given_mappings = mappings.is_a?(Proc) ? mappings.() : mappings.deep_dup if mappings
16
+ self.set_mappings ||= Generator.generate(given_mappings, fields: mappings_fields, type_name: type_name, physically_destroyable: respond_to?(:physically_destroy?) && physically_destroy?)
24
17
  end
25
18
  end
26
19
  end
data/lib/elos/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Elos
2
- VERSION = '1.0.23'
2
+ VERSION = '1.0.24'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 1.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsuri Moriya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-07 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -151,10 +151,12 @@ files:
151
151
  - lib/elos/helpers.rb
152
152
  - lib/elos/index.rb
153
153
  - lib/elos/index/attributes.rb
154
+ - lib/elos/index/attributes/keys_guesser.rb
154
155
  - lib/elos/index/core.rb
155
156
  - lib/elos/index/indexable.rb
156
157
  - lib/elos/index/locatable.rb
157
158
  - lib/elos/index/mappings.rb
159
+ - lib/elos/index/mappings/generator.rb
158
160
  - lib/elos/index/model.rb
159
161
  - lib/elos/index/model/assignable.rb
160
162
  - lib/elos/index/model/attributes.rb