neo4j 3.0.4 → 4.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +22 -0
- data/README.md +4 -0
- data/config/neo4j/config.yml +3 -1
- data/lib/neo4j/active_node/has_n/association.rb +4 -3
- data/lib/neo4j/active_node/id_property.rb +1 -1
- data/lib/neo4j/active_node/initialize.rb +1 -1
- data/lib/neo4j/active_node/labels.rb +20 -13
- data/lib/neo4j/active_node/query/query_proxy.rb +41 -16
- data/lib/neo4j/active_node/query/query_proxy_methods.rb +15 -3
- data/lib/neo4j/active_node/scope.rb +59 -2
- data/lib/neo4j/active_node.rb +13 -11
- data/lib/neo4j/active_rel/initialize.rb +1 -1
- data/lib/neo4j/active_rel/persistence.rb +3 -2
- data/lib/neo4j/active_rel/property.rb +0 -10
- data/lib/neo4j/active_rel/query.rb +0 -4
- data/lib/neo4j/active_rel/rel_wrapper.rb +15 -4
- data/lib/neo4j/active_rel/types.rb +54 -0
- data/lib/neo4j/active_rel.rb +5 -2
- data/lib/neo4j/paginated.rb +1 -1
- data/lib/neo4j/shared/persistence.rb +43 -7
- data/lib/neo4j/shared/property.rb +2 -6
- data/lib/neo4j/shared/rel_type_converters.rb +44 -0
- data/lib/neo4j/shared/serialized_properties.rb +29 -0
- data/lib/neo4j/shared/type_converters.rb +177 -0
- data/lib/neo4j/type_converters.rb +3 -166
- data/lib/neo4j/version.rb +1 -1
- data/lib/neo4j.rb +8 -4
- data/neo4j.gemspec +1 -1
- metadata +11 -8
- data/lib/neo4j/active_node/serialized_properties.rb +0 -21
data/lib/neo4j/active_rel.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
module Neo4j
|
2
2
|
|
3
3
|
# Makes Neo4j Relationships more or less act like ActiveRecord objects.
|
4
|
+
# See documentation at https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel
|
4
5
|
module ActiveRel
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
8
|
include Neo4j::Shared
|
8
9
|
include Neo4j::ActiveRel::Initialize
|
9
10
|
include Neo4j::Shared::Identity
|
11
|
+
include Neo4j::Shared::SerializedProperties
|
10
12
|
include Neo4j::ActiveRel::Property
|
11
13
|
include Neo4j::ActiveRel::Persistence
|
12
14
|
include Neo4j::ActiveRel::Validations
|
13
15
|
include Neo4j::ActiveRel::Callbacks
|
14
16
|
include Neo4j::ActiveRel::Query
|
17
|
+
include Neo4j::ActiveRel::Types
|
15
18
|
|
16
19
|
class FrozenRelError < StandardError; end
|
17
20
|
|
@@ -28,8 +31,8 @@ module Neo4j
|
|
28
31
|
def self.inherited(other)
|
29
32
|
super
|
30
33
|
end
|
31
|
-
|
32
|
-
cache_class unless cached_class?
|
33
34
|
end
|
35
|
+
|
36
|
+
ActiveSupport.run_load_hooks(:active_rel, self)
|
34
37
|
end
|
35
38
|
end
|
data/lib/neo4j/paginated.rb
CHANGED
@@ -8,7 +8,7 @@ module Neo4j
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.create_from(source, page, per_page, order = nil)
|
11
|
-
target = source.node_var
|
11
|
+
target = source.node_var || source.identity
|
12
12
|
partial = source.skip((page - 1) * per_page).limit(per_page)
|
13
13
|
ordered_partial, ordered_source = if order
|
14
14
|
[partial.order_by(order), source.query.with("#{target} as #{target}").pluck("COUNT(#{target})").first]
|
@@ -2,7 +2,9 @@ module Neo4j::Shared
|
|
2
2
|
module Persistence
|
3
3
|
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
include Neo4j::TypeConverters
|
5
|
+
include Neo4j::Shared::TypeConverters
|
6
|
+
|
7
|
+
USES_CLASSNAME = []
|
6
8
|
|
7
9
|
def update_model
|
8
10
|
if changed_attributes && !changed_attributes.empty?
|
@@ -153,16 +155,50 @@ module Neo4j::Shared
|
|
153
155
|
end
|
154
156
|
|
155
157
|
def update_magic_properties
|
156
|
-
self.updated_at = DateTime.now if respond_to?(:updated_at=) && changed?
|
158
|
+
self.updated_at = DateTime.now if respond_to?(:updated_at=) && changed? && !updated_at_changed?
|
157
159
|
end
|
158
160
|
|
159
|
-
|
160
|
-
|
161
|
+
# Inserts the _classname property into an object's properties during object creation.
|
162
|
+
def set_classname(props, check_version = true)
|
163
|
+
props[:_classname] = self.class.name if self.class.cached_class?(check_version)
|
161
164
|
end
|
162
165
|
|
163
166
|
def set_timestamps
|
164
|
-
|
165
|
-
self.
|
167
|
+
now = DateTime.now
|
168
|
+
self.created_at ||= now if respond_to?(:created_at=)
|
169
|
+
self.updated_at ||= now if respond_to?(:updated_at=)
|
170
|
+
end
|
171
|
+
|
172
|
+
module ClassMethods
|
173
|
+
# Determines whether a model should insert a _classname property. This can be used to override the automatic matching of returned
|
174
|
+
# objects to models.
|
175
|
+
def cached_class?(check_version = true)
|
176
|
+
uses_classname? || (!!Neo4j::Config[:cache_class_names] && (check_version ? neo4j_session.version < '2.1.5' : true))
|
177
|
+
end
|
178
|
+
|
179
|
+
# @return [Boolean] status of whether this model will add a _classname property
|
180
|
+
def uses_classname?
|
181
|
+
Neo4j::Shared::Persistence::USES_CLASSNAME.include?(self.name)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Adds this model to the USES_CLASSNAME array. When new rels/nodes are created, a _classname property will be added. This will override the
|
185
|
+
# automatic matching of label/rel type to model.
|
186
|
+
#
|
187
|
+
# You'd want to do this if you have multiple models for the same label or relationship type. When it comes to labels, there isn't really any
|
188
|
+
# reason to do this because you can have multiple labels; on the other hand, an argument can be made for doing this with relationships since
|
189
|
+
# rel type is a bit more restrictive.
|
190
|
+
#
|
191
|
+
# It could also be speculated that there's a slight performance boost to using _classname since the gem immediately knows what model is responsible
|
192
|
+
# for a returned object. At the same time, it is a bit restrictive and changing it can be a bit of a PITA. Use carefully!
|
193
|
+
def set_classname
|
194
|
+
Neo4j::Shared::Persistence::USES_CLASSNAME << self.name
|
195
|
+
end
|
196
|
+
|
197
|
+
# Removes this model from the USES_CLASSNAME array. When new rels/nodes are create, no _classname property will be injected. Upon returning of
|
198
|
+
# the object from the database, it will be matched to a model using its relationship type or labels.
|
199
|
+
def unset_classname
|
200
|
+
Neo4j::Shared::Persistence::USES_CLASSNAME.delete self.name
|
201
|
+
end
|
166
202
|
end
|
167
203
|
end
|
168
|
-
end
|
204
|
+
end
|
@@ -184,16 +184,12 @@ module Neo4j::Shared
|
|
184
184
|
def attribute!(name, options={})
|
185
185
|
super(name, options)
|
186
186
|
define_method("#{name}=") do |value|
|
187
|
-
typecast_value = typecast_attribute(
|
187
|
+
typecast_value = typecast_attribute(_attribute_typecaster(name), value)
|
188
188
|
send("#{name}_will_change!") unless typecast_value == read_attribute(name)
|
189
189
|
super(value)
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
def cached_class?
|
194
|
-
!!Neo4j::Config[:cache_class_names]
|
195
|
-
end
|
196
|
-
|
197
193
|
private
|
198
194
|
|
199
195
|
def constraint_or_index(name, options)
|
@@ -220,7 +216,7 @@ module Neo4j::Shared
|
|
220
216
|
end
|
221
217
|
|
222
218
|
def set_stamp_type(name, options)
|
223
|
-
options[:type]
|
219
|
+
options[:type] ||= DateTime if (name.to_sym == :created_at || name.to_sym == :updated_at)
|
224
220
|
end
|
225
221
|
|
226
222
|
# ActiveAttr does not handle "Time", Rails and Neo4j.rb 2.3 did
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Neo4j::Shared
|
2
|
+
|
3
|
+
# This module controls changes to relationship type based on Neo4j::Config.transform_rel_type.
|
4
|
+
# It's used whenever a rel type is automatically determined based on ActiveRel model name or
|
5
|
+
# association type.
|
6
|
+
module RelTypeConverters
|
7
|
+
|
8
|
+
def decorated_rel_type(type)
|
9
|
+
@decorated_rel_type ||= Neo4j::Shared::RelTypeConverters.decorated_rel_type(type)
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Determines how relationship types should look when inferred based on association or ActiveRel model name.
|
14
|
+
# With the exception of `:none`, all options will call `underscore`, so `ThisClass` becomes `this_class`, with capitalization
|
15
|
+
# determined by the specific option passed.
|
16
|
+
# Valid options:
|
17
|
+
# * :upcase - `:this_class`, `ThisClass`, `thiS_claSs` (if you don't like yourself) becomes `THIS_CLASS`
|
18
|
+
# * :downcase - same as above, only... downcased.
|
19
|
+
# * :legacy - downcases and prepends `#`, so ThisClass becomes `#this_class`
|
20
|
+
# * :none - uses the string version of whatever is passed with no modifications
|
21
|
+
def rel_transformer
|
22
|
+
@rel_transformer ||= Neo4j::Config[:transform_rel_type].nil? ? :upcase : Neo4j::Config[:transform_rel_type]
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [String,Symbol] type The raw string or symbol to be used as the basis of the relationship type
|
26
|
+
# @return [String] A string that conforms to the set rel type conversion setting.
|
27
|
+
def decorated_rel_type(type)
|
28
|
+
type = type.to_s
|
29
|
+
case rel_transformer
|
30
|
+
when :upcase
|
31
|
+
type.underscore.upcase
|
32
|
+
when :downcase
|
33
|
+
type.underscore.downcase
|
34
|
+
when :legacy
|
35
|
+
"##{type.underscore.downcase}"
|
36
|
+
when :none
|
37
|
+
type
|
38
|
+
else
|
39
|
+
type.underscore.upcase
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Neo4j::Shared
|
2
|
+
# This module adds the `serialize` class method. It lets you store hashes and arrays in Neo4j properties.
|
3
|
+
# Be aware that you won't be able to search within serialized properties and stuff use indexes. If you do a regex search for portion of a string
|
4
|
+
# property, the search happens in Cypher and you may take a performance hit.
|
5
|
+
#
|
6
|
+
# See type_converters.rb for the serialization process.
|
7
|
+
module SerializedProperties
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
def serialized_properties
|
11
|
+
self.class.serialized_properties
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def serialized_properties
|
16
|
+
@serialize || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def serialized_properties=(serialize_hash)
|
20
|
+
@serialize = serialize_hash.clone
|
21
|
+
end
|
22
|
+
|
23
|
+
def serialize(name, coder = JSON)
|
24
|
+
@serialize ||= {}
|
25
|
+
@serialize[name] = coder
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
module Neo4j::Shared
|
2
|
+
module TypeConverters
|
3
|
+
|
4
|
+
# Converts Date objects to Java long types. Must be timezone UTC.
|
5
|
+
class DateConverter
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def convert_type
|
9
|
+
Date
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_db(value)
|
13
|
+
return nil if value.nil?
|
14
|
+
Time.utc(value.year, value.month, value.day).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_ruby(value)
|
18
|
+
return nil if value.nil?
|
19
|
+
Time.at(value).utc.to_date
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Converts DateTime objects to and from Java long types. Must be timezone UTC.
|
26
|
+
class DateTimeConverter
|
27
|
+
class << self
|
28
|
+
|
29
|
+
def convert_type
|
30
|
+
DateTime
|
31
|
+
end
|
32
|
+
|
33
|
+
# Converts the given DateTime (UTC) value to an Fixnum.
|
34
|
+
# DateTime values are automatically converted to UTC.
|
35
|
+
def to_db(value)
|
36
|
+
return nil if value.nil?
|
37
|
+
value = value.new_offset(0) if value.respond_to?(:new_offset)
|
38
|
+
if value.class == Date
|
39
|
+
Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
|
40
|
+
else
|
41
|
+
Time.utc(value.year, value.month, value.day, value.hour, value.min, value.sec).to_i
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_ruby(value)
|
46
|
+
return nil if value.nil?
|
47
|
+
t = case value
|
48
|
+
when Fixnum
|
49
|
+
Time.at(value).utc
|
50
|
+
when String
|
51
|
+
DateTime.strptime(value, '%Y-%m-%d %H:%M:%S %z')
|
52
|
+
else
|
53
|
+
raise ArgumentError, "Invalid value type for DateType property: #{value.inspect}"
|
54
|
+
end
|
55
|
+
|
56
|
+
DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class TimeConverter
|
63
|
+
class << self
|
64
|
+
|
65
|
+
def convert_type
|
66
|
+
Time
|
67
|
+
end
|
68
|
+
|
69
|
+
# Converts the given DateTime (UTC) value to an Fixnum.
|
70
|
+
# Only utc times are supported !
|
71
|
+
def to_db(value)
|
72
|
+
return nil if value.nil?
|
73
|
+
if value.class == Date
|
74
|
+
Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
|
75
|
+
else
|
76
|
+
value.utc.to_i
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_ruby(value)
|
81
|
+
return nil if value.nil?
|
82
|
+
Time.at(value).utc
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Converts hash to/from YAML
|
89
|
+
class YAMLConverter
|
90
|
+
class << self
|
91
|
+
|
92
|
+
def convert_type
|
93
|
+
Hash
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_db(value)
|
97
|
+
return nil if value.nil?
|
98
|
+
Psych.dump(value)
|
99
|
+
end
|
100
|
+
|
101
|
+
def to_ruby(value)
|
102
|
+
return nil if value.nil?
|
103
|
+
Psych.load(value)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Converts hash to/from JSON
|
109
|
+
class JSONConverter
|
110
|
+
class << self
|
111
|
+
|
112
|
+
def convert_type
|
113
|
+
JSON
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_db(value)
|
117
|
+
return nil if value.nil?
|
118
|
+
value.to_json
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_ruby(value)
|
122
|
+
return nil if value.nil?
|
123
|
+
JSON.parse(value, quirks_mode: true)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
def convert_properties_to(medium, properties)
|
131
|
+
# Perform type conversion
|
132
|
+
serialize = self.respond_to?(:serialized_properties) ? self.serialized_properties : {}
|
133
|
+
properties = properties.inject({}) do |new_attributes, key_value_pair|
|
134
|
+
attr, value = key_value_pair
|
135
|
+
|
136
|
+
# skip "secret" undeclared attributes such as uuid
|
137
|
+
next new_attributes unless self.class.attributes[attr]
|
138
|
+
|
139
|
+
type = serialize.has_key?(attr.to_sym) ? serialize[attr.to_sym] : self.class._attribute_type(attr)
|
140
|
+
new_attributes[attr] = if TypeConverters.converters[type].nil?
|
141
|
+
value
|
142
|
+
else
|
143
|
+
TypeConverters.send "to_#{medium}", value, type
|
144
|
+
end
|
145
|
+
new_attributes
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class << self
|
150
|
+
|
151
|
+
# Converts the value to ruby from a Neo4j database value if there is a converter for given type
|
152
|
+
def to_ruby(value, type = nil)
|
153
|
+
found_converter = converters[type]
|
154
|
+
found_converter ? found_converter.to_ruby(value) : value
|
155
|
+
end
|
156
|
+
|
157
|
+
# Converts the value to a Neo4j database value from ruby if there is a converter for given type
|
158
|
+
def to_db(value, type = nil)
|
159
|
+
found_converter = converters[type]
|
160
|
+
found_converter ? found_converter.to_db(value) : value
|
161
|
+
end
|
162
|
+
|
163
|
+
def converters
|
164
|
+
@converters ||= begin
|
165
|
+
Neo4j::Shared::TypeConverters.constants.find_all do |c|
|
166
|
+
Neo4j::Shared::TypeConverters.const_get(c).respond_to?(:convert_type)
|
167
|
+
end.map do |c|
|
168
|
+
Neo4j::Shared::TypeConverters.const_get(c)
|
169
|
+
end.inject({}) do |ack, t|
|
170
|
+
ack[t.convert_type] = t
|
171
|
+
ack
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -1,170 +1,7 @@
|
|
1
1
|
module Neo4j
|
2
|
-
|
3
2
|
module TypeConverters
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def convert_type
|
10
|
-
Date
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_db(value)
|
14
|
-
return nil if value.nil?
|
15
|
-
Time.utc(value.year, value.month, value.day).to_i
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_ruby(value)
|
19
|
-
return nil if value.nil?
|
20
|
-
Time.at(value).utc.to_date
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Converts DateTime objects to and from Java long types. Must be timezone UTC.
|
27
|
-
class DateTimeConverter
|
28
|
-
class << self
|
29
|
-
|
30
|
-
def convert_type
|
31
|
-
DateTime
|
32
|
-
end
|
33
|
-
|
34
|
-
# Converts the given DateTime (UTC) value to an Fixnum.
|
35
|
-
# DateTime values are automatically converted to UTC.
|
36
|
-
def to_db(value)
|
37
|
-
return nil if value.nil?
|
38
|
-
value = value.new_offset(0) if value.respond_to?(:new_offset)
|
39
|
-
if value.class == Date
|
40
|
-
Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
|
41
|
-
else
|
42
|
-
Time.utc(value.year, value.month, value.day, value.hour, value.min, value.sec).to_i
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_ruby(value)
|
47
|
-
return nil if value.nil?
|
48
|
-
t = Time.at(value).utc
|
49
|
-
DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class TimeConverter
|
56
|
-
class << self
|
57
|
-
|
58
|
-
def convert_type
|
59
|
-
Time
|
60
|
-
end
|
61
|
-
|
62
|
-
# Converts the given DateTime (UTC) value to an Fixnum.
|
63
|
-
# Only utc times are supported !
|
64
|
-
def to_db(value)
|
65
|
-
return nil if value.nil?
|
66
|
-
if value.class == Date
|
67
|
-
Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
|
68
|
-
else
|
69
|
-
value.utc.to_i
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def to_ruby(value)
|
74
|
-
return nil if value.nil?
|
75
|
-
Time.at(value).utc
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# Converts hash to/from YAML
|
82
|
-
class YAMLConverter
|
83
|
-
class << self
|
84
|
-
|
85
|
-
def convert_type
|
86
|
-
Hash
|
87
|
-
end
|
88
|
-
|
89
|
-
def to_db(value)
|
90
|
-
return nil if value.nil?
|
91
|
-
Psych.dump(value)
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_ruby(value)
|
95
|
-
return nil if value.nil?
|
96
|
-
Psych.load(value)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# Converts hash to/from JSON
|
102
|
-
class JSONConverter
|
103
|
-
class << self
|
104
|
-
|
105
|
-
def convert_type
|
106
|
-
JSON
|
107
|
-
end
|
108
|
-
|
109
|
-
def to_db(value)
|
110
|
-
return nil if value.nil?
|
111
|
-
value.to_json
|
112
|
-
end
|
113
|
-
|
114
|
-
def to_ruby(value)
|
115
|
-
return nil if value.nil?
|
116
|
-
JSON.parse(value, quirks_mode: true)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
def convert_properties_to(medium, properties)
|
124
|
-
# Perform type conversion
|
125
|
-
serialize = self.respond_to?(:serialized_properties) ? self.serialized_properties : {}
|
126
|
-
properties = properties.inject({}) do |new_attributes, key_value_pair|
|
127
|
-
attr, value = key_value_pair
|
128
|
-
|
129
|
-
# skip "secret" undeclared attributes such as uuid
|
130
|
-
next new_attributes unless self.class.attributes[attr]
|
131
|
-
|
132
|
-
type = serialize.has_key?(attr.to_sym) ? serialize[attr.to_sym] : self.class._attribute_type(attr)
|
133
|
-
new_attributes[attr] = if TypeConverters.converters[type].nil?
|
134
|
-
value
|
135
|
-
else
|
136
|
-
TypeConverters.send "to_#{medium}", value, type
|
137
|
-
end
|
138
|
-
new_attributes
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
class << self
|
143
|
-
|
144
|
-
# Converts the value to ruby from a Neo4j database value if there is a converter for given type
|
145
|
-
def to_ruby(value, type = nil)
|
146
|
-
found_converter = converters[type]
|
147
|
-
found_converter ? found_converter.to_ruby(value) : value
|
148
|
-
end
|
149
|
-
|
150
|
-
# Converts the value to a Neo4j database value from ruby if there is a converter for given type
|
151
|
-
def to_db(value, type = nil)
|
152
|
-
found_converter = converters[type]
|
153
|
-
found_converter ? found_converter.to_db(value) : value
|
154
|
-
end
|
155
|
-
|
156
|
-
def converters
|
157
|
-
@converters ||= begin
|
158
|
-
Neo4j::TypeConverters.constants.find_all do |c|
|
159
|
-
Neo4j::TypeConverters.const_get(c).respond_to?(:convert_type)
|
160
|
-
end.map do |c|
|
161
|
-
Neo4j::TypeConverters.const_get(c)
|
162
|
-
end.inject({}) do |ack, t|
|
163
|
-
ack[t.convert_type] = t
|
164
|
-
ack
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
3
|
+
# This exists for legacy purposes. Some gems (*coughDevisecough*) that the Neo4jrb project does not own
|
4
|
+
# may contain references to this file. We will remove it once that has been dealt with.
|
5
|
+
include Neo4j::Shared::TypeConverters
|
169
6
|
end
|
170
7
|
end
|
data/lib/neo4j/version.rb
CHANGED
data/lib/neo4j.rb
CHANGED
@@ -19,6 +19,8 @@ require 'neo4j/config'
|
|
19
19
|
require 'neo4j/wrapper'
|
20
20
|
require 'neo4j/active_rel/rel_wrapper'
|
21
21
|
require 'neo4j/active_node/node_wrapper'
|
22
|
+
require 'neo4j/shared/type_converters'
|
23
|
+
require 'neo4j/shared/rel_type_converters'
|
22
24
|
require 'neo4j/type_converters'
|
23
25
|
require 'neo4j/paginated'
|
24
26
|
|
@@ -27,6 +29,7 @@ require 'neo4j/shared/property'
|
|
27
29
|
require 'neo4j/shared/persistence'
|
28
30
|
require 'neo4j/shared/validations'
|
29
31
|
require 'neo4j/shared/identity'
|
32
|
+
require 'neo4j/shared/serialized_properties'
|
30
33
|
require 'neo4j/shared'
|
31
34
|
|
32
35
|
require 'neo4j/active_rel/callbacks'
|
@@ -36,6 +39,7 @@ require 'neo4j/active_rel/persistence'
|
|
36
39
|
require 'neo4j/active_rel/validations'
|
37
40
|
require 'neo4j/active_rel/query'
|
38
41
|
require 'neo4j/active_rel/related_node'
|
42
|
+
require 'neo4j/active_rel/types'
|
39
43
|
require 'neo4j/active_rel'
|
40
44
|
|
41
45
|
require 'neo4j/active_node/query_methods'
|
@@ -54,11 +58,11 @@ require 'neo4j/active_node/has_n'
|
|
54
58
|
require 'neo4j/active_node/has_n/association'
|
55
59
|
require 'neo4j/active_node/query/query_proxy'
|
56
60
|
require 'neo4j/active_node/query'
|
57
|
-
require 'neo4j/active_node/serialized_properties'
|
58
61
|
require 'neo4j/active_node/scope'
|
59
62
|
require 'neo4j/active_node'
|
60
63
|
|
61
64
|
require 'neo4j/active_node/orm_adapter'
|
62
|
-
|
63
|
-
require 'rails/generators
|
64
|
-
|
65
|
+
if defined?(Rails)
|
66
|
+
require 'rails/generators'
|
67
|
+
require 'rails/generators/neo4j_generator'
|
68
|
+
end
|
data/neo4j.gemspec
CHANGED
@@ -31,7 +31,7 @@ A Neo4j OGM (Object-Graph-Mapper) for use in Ruby on Rails and Rack frameworks h
|
|
31
31
|
s.add_dependency("activesupport", "~> 4")
|
32
32
|
s.add_dependency("railties", "~> 4")
|
33
33
|
s.add_dependency('active_attr', "~> 0.8")
|
34
|
-
s.add_dependency("neo4j-core", "~> 3.0
|
34
|
+
s.add_dependency("neo4j-core", "~> 3.1.0")
|
35
35
|
|
36
36
|
if RUBY_PLATFORM =~ /java/
|
37
37
|
s.add_dependency("neo4j-community", '~> 2.0')
|
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:
|
4
|
+
version: 4.0.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Ronge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.0
|
89
|
+
version: 3.1.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.0
|
96
|
+
version: 3.1.0
|
97
97
|
description: |
|
98
98
|
A Neo4j OGM (Object-Graph-Mapper) for use in Ruby on Rails and Rack frameworks heavily inspired by ActiveRecord.
|
99
99
|
email: andreas.ronge@gmail.com
|
@@ -131,7 +131,6 @@ files:
|
|
131
131
|
- lib/neo4j/active_node/reflection.rb
|
132
132
|
- lib/neo4j/active_node/rels.rb
|
133
133
|
- lib/neo4j/active_node/scope.rb
|
134
|
-
- lib/neo4j/active_node/serialized_properties.rb
|
135
134
|
- lib/neo4j/active_node/validations.rb
|
136
135
|
- lib/neo4j/active_rel.rb
|
137
136
|
- lib/neo4j/active_rel/callbacks.rb
|
@@ -141,6 +140,7 @@ files:
|
|
141
140
|
- lib/neo4j/active_rel/query.rb
|
142
141
|
- lib/neo4j/active_rel/rel_wrapper.rb
|
143
142
|
- lib/neo4j/active_rel/related_node.rb
|
143
|
+
- lib/neo4j/active_rel/types.rb
|
144
144
|
- lib/neo4j/active_rel/validations.rb
|
145
145
|
- lib/neo4j/config.rb
|
146
146
|
- lib/neo4j/migration.rb
|
@@ -151,6 +151,9 @@ files:
|
|
151
151
|
- lib/neo4j/shared/identity.rb
|
152
152
|
- lib/neo4j/shared/persistence.rb
|
153
153
|
- lib/neo4j/shared/property.rb
|
154
|
+
- lib/neo4j/shared/rel_type_converters.rb
|
155
|
+
- lib/neo4j/shared/serialized_properties.rb
|
156
|
+
- lib/neo4j/shared/type_converters.rb
|
154
157
|
- lib/neo4j/shared/validations.rb
|
155
158
|
- lib/neo4j/tasks/migration.rake
|
156
159
|
- lib/neo4j/type_converters.rb
|
@@ -182,12 +185,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
185
|
version: 1.9.1
|
183
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
187
|
requirements:
|
185
|
-
- - "
|
188
|
+
- - ">"
|
186
189
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
190
|
+
version: 1.3.1
|
188
191
|
requirements: []
|
189
192
|
rubyforge_project: neo4j
|
190
|
-
rubygems_version: 2.4.
|
193
|
+
rubygems_version: 2.4.3
|
191
194
|
signing_key:
|
192
195
|
specification_version: 4
|
193
196
|
summary: A graph database for Ruby
|