neo4j 5.0.15 → 5.1.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -5
- data/Gemfile +1 -1
- data/README.md +8 -0
- data/lib/neo4j.rb +4 -0
- data/lib/neo4j/active_node.rb +3 -1
- data/lib/neo4j/active_node/dependent/association_methods.rb +4 -2
- data/lib/neo4j/active_node/dependent/query_proxy_methods.rb +3 -3
- data/lib/neo4j/active_node/has_n.rb +103 -36
- data/lib/neo4j/active_node/has_n/association.rb +10 -33
- data/lib/neo4j/active_node/has_n/association_cypher_methods.rb +108 -0
- data/lib/neo4j/active_node/id_property.rb +19 -11
- data/lib/neo4j/active_node/id_property/accessor.rb +62 -0
- data/lib/neo4j/active_node/labels.rb +13 -2
- data/lib/neo4j/active_node/persistence.rb +19 -4
- data/lib/neo4j/active_node/property.rb +4 -3
- data/lib/neo4j/active_node/query/query_proxy.rb +29 -13
- data/lib/neo4j/active_node/query/query_proxy_eager_loading.rb +8 -0
- data/lib/neo4j/active_node/query/query_proxy_enumerable.rb +7 -0
- data/lib/neo4j/active_node/query/query_proxy_link.rb +16 -6
- data/lib/neo4j/active_node/query/query_proxy_methods.rb +4 -0
- data/lib/neo4j/active_node/query/query_proxy_unpersisted.rb +17 -0
- data/lib/neo4j/active_node/unpersisted.rb +49 -0
- data/lib/neo4j/active_node/validations.rb +1 -1
- data/lib/neo4j/active_rel.rb +17 -0
- data/lib/neo4j/active_rel/persistence.rb +10 -5
- data/lib/neo4j/active_rel/property.rb +17 -5
- data/lib/neo4j/railtie.rb +2 -1
- data/lib/neo4j/shared/declared_property_manager.rb +10 -0
- data/lib/neo4j/shared/initialize.rb +3 -3
- data/lib/neo4j/shared/property.rb +7 -51
- data/lib/neo4j/shared/property/default_property.rb +0 -0
- data/lib/neo4j/shared/type_converters.rb +49 -6
- data/lib/neo4j/shared/typecaster.rb +22 -18
- data/lib/neo4j/shared/validations.rb +1 -1
- data/lib/neo4j/version.rb +1 -1
- data/neo4j.gemspec +1 -1
- metadata +12 -7
@@ -9,6 +9,10 @@ module Neo4j::Shared
|
|
9
9
|
Date
|
10
10
|
end
|
11
11
|
|
12
|
+
def db_type
|
13
|
+
Integer
|
14
|
+
end
|
15
|
+
|
12
16
|
def to_db(value)
|
13
17
|
Time.utc(value.year, value.month, value.day).to_i
|
14
18
|
end
|
@@ -26,6 +30,10 @@ module Neo4j::Shared
|
|
26
30
|
DateTime
|
27
31
|
end
|
28
32
|
|
33
|
+
def db_type
|
34
|
+
Integer
|
35
|
+
end
|
36
|
+
|
29
37
|
# Converts the given DateTime (UTC) value to an Integer.
|
30
38
|
# DateTime values are automatically converted to UTC.
|
31
39
|
def to_db(value)
|
@@ -59,9 +67,16 @@ module Neo4j::Shared
|
|
59
67
|
Time
|
60
68
|
end
|
61
69
|
|
70
|
+
# ActiveAttr, which assists with property management, does not recognize Time as a valid type. We tell it to interpret it as
|
71
|
+
# Integer, as it will be when saved to the database.
|
62
72
|
def primitive_type
|
63
73
|
Integer
|
64
74
|
end
|
75
|
+
|
76
|
+
def db_type
|
77
|
+
Integer
|
78
|
+
end
|
79
|
+
|
65
80
|
# Converts the given DateTime (UTC) value to an Integer.
|
66
81
|
# Only utc times are supported !
|
67
82
|
def to_db(value)
|
@@ -86,6 +101,10 @@ module Neo4j::Shared
|
|
86
101
|
Hash
|
87
102
|
end
|
88
103
|
|
104
|
+
def db_type
|
105
|
+
String
|
106
|
+
end
|
107
|
+
|
89
108
|
def to_db(value)
|
90
109
|
Psych.dump(value)
|
91
110
|
end
|
@@ -103,6 +122,10 @@ module Neo4j::Shared
|
|
103
122
|
JSON
|
104
123
|
end
|
105
124
|
|
125
|
+
def db_type
|
126
|
+
String
|
127
|
+
end
|
128
|
+
|
106
129
|
def to_db(value)
|
107
130
|
value.to_json
|
108
131
|
end
|
@@ -113,14 +136,26 @@ module Neo4j::Shared
|
|
113
136
|
end
|
114
137
|
end
|
115
138
|
|
139
|
+
# Modifies a hash's values to be of types acceptable to Neo4j or matching what the user defined using `type` in property definitions.
|
140
|
+
# @param [Neo4j::Shared::Property] obj A node or rel that mixes in the Property module
|
141
|
+
# @param [Symbol] medium Indicates the type of conversion to perform.
|
142
|
+
# @param [Hash] properties A hash of symbol-keyed properties for conversion.
|
116
143
|
def convert_properties_to(obj, medium, properties)
|
117
|
-
|
118
|
-
properties.each_pair do |
|
119
|
-
next if skip_conversion?(obj,
|
120
|
-
properties[
|
144
|
+
direction = medium == :ruby ? :to_ruby : :to_db
|
145
|
+
properties.each_pair do |key, value|
|
146
|
+
next if skip_conversion?(obj, key, value)
|
147
|
+
properties[key] = convert_property(key, value, direction)
|
121
148
|
end
|
122
149
|
end
|
123
150
|
|
151
|
+
# Converts a single property from its current format to its db- or Ruby-expected output type.
|
152
|
+
# @param [Symbol] key A property declared on the model
|
153
|
+
# @param value The value intended for conversion
|
154
|
+
# @param [Symbol] direction Either :to_ruby or :to_db, indicates the type of conversion to perform
|
155
|
+
def convert_property(key, value, direction)
|
156
|
+
converted_property(primitive_type(key.to_sym), value, direction)
|
157
|
+
end
|
158
|
+
|
124
159
|
private
|
125
160
|
|
126
161
|
def converted_property(type, value, converter)
|
@@ -156,7 +191,6 @@ module Neo4j::Shared
|
|
156
191
|
end
|
157
192
|
end
|
158
193
|
|
159
|
-
|
160
194
|
def typecaster_for(primitive_type)
|
161
195
|
return nil if primitive_type.nil?
|
162
196
|
converters.key?(primitive_type) ? converters[primitive_type] : nil
|
@@ -166,7 +200,16 @@ module Neo4j::Shared
|
|
166
200
|
def to_other(direction, value, type)
|
167
201
|
fail "Unknown direction given: #{direction}" unless direction == :to_ruby || direction == :to_db
|
168
202
|
found_converter = converters[type]
|
169
|
-
|
203
|
+
return value unless found_converter
|
204
|
+
return value if direction == :to_db && formatted_for_db?(found_converter, value)
|
205
|
+
found_converter.send(direction, value)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Attempts to determine whether conversion should be skipped because the object is already of the anticipated output type.
|
209
|
+
# @param [#convert_type] found_converter An object that responds to #convert_type, hinting that it is a type converter.
|
210
|
+
# @param value The value for conversion.
|
211
|
+
def formatted_for_db?(found_converter, value)
|
212
|
+
found_converter.respond_to?(:db_type) && value.is_a?(found_converter.db_type)
|
170
213
|
end
|
171
214
|
|
172
215
|
def register_converter(converter)
|
@@ -1,30 +1,34 @@
|
|
1
1
|
module Neo4j
|
2
2
|
module Shared
|
3
3
|
# This module provides a convenient way of registering a custom Typecasting class. Custom Typecasters all follow a simple pattern.
|
4
|
+
#
|
4
5
|
# EXAMPLE:
|
5
|
-
# class RangeConverter
|
6
|
-
# class << self
|
7
|
-
# def primitive_type
|
8
|
-
# String
|
9
|
-
# end
|
10
6
|
#
|
11
|
-
#
|
12
|
-
# Range
|
13
|
-
# end
|
7
|
+
# .. code-block:: ruby
|
14
8
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
9
|
+
# class RangeConverter
|
10
|
+
# class << self
|
11
|
+
# def primitive_type
|
12
|
+
# String
|
13
|
+
# end
|
18
14
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
15
|
+
# def convert_type
|
16
|
+
# Range
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def to_db(value)
|
20
|
+
# value.to_s
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# def to_ruby(value)
|
24
|
+
# ends = value.to_s.split('..').map { |d| Integer(d) }
|
25
|
+
# ends[0]..ends[1]
|
26
|
+
# end
|
27
|
+
# alias_method :call, :to_ruby
|
22
28
|
# end
|
23
|
-
# alias_method :call, :to_ruby
|
24
|
-
# end
|
25
29
|
#
|
26
|
-
#
|
27
|
-
#
|
30
|
+
# include Neo4j::Shared::Typecaster
|
31
|
+
# end
|
28
32
|
#
|
29
33
|
# This would allow you to use `property :my_prop, type: Range` in a model.
|
30
34
|
# Each method and the `alias_method` call is required. Make sure the module inclusion happens at the end of the file.
|
data/lib/neo4j/version.rb
CHANGED
data/neo4j.gemspec
CHANGED
@@ -30,7 +30,7 @@ A Neo4j OGM (Object-Graph-Mapper) for use in Ruby on Rails and Rack frameworks h
|
|
30
30
|
s.add_dependency('activemodel', '~> 4')
|
31
31
|
s.add_dependency('activesupport', '~> 4')
|
32
32
|
s.add_dependency('active_attr', '~> 0.8')
|
33
|
-
s.add_dependency('neo4j-core', '~> 5.0.1')
|
33
|
+
s.add_dependency('neo4j-core', '~> 5.1.0.rc.1')
|
34
34
|
s.add_dependency('neo4j-community', '~> 2.0') if RUBY_PLATFORM =~ /java/
|
35
35
|
s.add_development_dependency('railties', '~> 4')
|
36
36
|
s.add_development_dependency('pry')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.1.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge, Brian Underwood, Chris Grigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 5.0.1
|
75
|
+
version: 5.1.0.rc.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 5.0.1
|
82
|
+
version: 5.1.0.rc.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: railties
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,7 +231,9 @@ files:
|
|
231
231
|
- lib/neo4j/active_node/dependent/query_proxy_methods.rb
|
232
232
|
- lib/neo4j/active_node/has_n.rb
|
233
233
|
- lib/neo4j/active_node/has_n/association.rb
|
234
|
+
- lib/neo4j/active_node/has_n/association_cypher_methods.rb
|
234
235
|
- lib/neo4j/active_node/id_property.rb
|
236
|
+
- lib/neo4j/active_node/id_property/accessor.rb
|
235
237
|
- lib/neo4j/active_node/initialize.rb
|
236
238
|
- lib/neo4j/active_node/labels.rb
|
237
239
|
- lib/neo4j/active_node/node_wrapper.rb
|
@@ -245,10 +247,12 @@ files:
|
|
245
247
|
- lib/neo4j/active_node/query/query_proxy_find_in_batches.rb
|
246
248
|
- lib/neo4j/active_node/query/query_proxy_link.rb
|
247
249
|
- lib/neo4j/active_node/query/query_proxy_methods.rb
|
250
|
+
- lib/neo4j/active_node/query/query_proxy_unpersisted.rb
|
248
251
|
- lib/neo4j/active_node/query_methods.rb
|
249
252
|
- lib/neo4j/active_node/reflection.rb
|
250
253
|
- lib/neo4j/active_node/rels.rb
|
251
254
|
- lib/neo4j/active_node/scope.rb
|
255
|
+
- lib/neo4j/active_node/unpersisted.rb
|
252
256
|
- lib/neo4j/active_node/validations.rb
|
253
257
|
- lib/neo4j/active_rel.rb
|
254
258
|
- lib/neo4j/active_rel/callbacks.rb
|
@@ -274,6 +278,7 @@ files:
|
|
274
278
|
- lib/neo4j/shared/initialize.rb
|
275
279
|
- lib/neo4j/shared/persistence.rb
|
276
280
|
- lib/neo4j/shared/property.rb
|
281
|
+
- lib/neo4j/shared/property/default_property.rb
|
277
282
|
- lib/neo4j/shared/rel_type_converters.rb
|
278
283
|
- lib/neo4j/shared/serialized_properties.rb
|
279
284
|
- lib/neo4j/shared/type_converters.rb
|
@@ -309,12 +314,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
314
|
version: 1.9.3
|
310
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
316
|
requirements:
|
312
|
-
- - "
|
317
|
+
- - ">"
|
313
318
|
- !ruby/object:Gem::Version
|
314
|
-
version:
|
319
|
+
version: 1.3.1
|
315
320
|
requirements: []
|
316
321
|
rubyforge_project: neo4j
|
317
|
-
rubygems_version: 2.4.
|
322
|
+
rubygems_version: 2.4.5
|
318
323
|
signing_key:
|
319
324
|
specification_version: 4
|
320
325
|
summary: A graph database for Ruby
|