neo4j-wrapper 0.0.1-java

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.
Files changed (88) hide show
  1. data/Gemfile +10 -0
  2. data/README.rdoc +64 -0
  3. data/lib/db/active_tx_log +1 -0
  4. data/lib/db/index/lucene/node/Person_exact/_0.fdt +0 -0
  5. data/lib/db/index/lucene/node/Person_exact/_0.fdx +0 -0
  6. data/lib/db/index/lucene/node/Person_exact/_0.fnm +1 -0
  7. data/lib/db/index/lucene/node/Person_exact/_0.frq +0 -0
  8. data/lib/db/index/lucene/node/Person_exact/_0.nrm +1 -0
  9. data/lib/db/index/lucene/node/Person_exact/_0.prx +0 -0
  10. data/lib/db/index/lucene/node/Person_exact/_0.tii +0 -0
  11. data/lib/db/index/lucene/node/Person_exact/_0.tis +0 -0
  12. data/lib/db/index/lucene/node/Person_exact/_1.fdt +0 -0
  13. data/lib/db/index/lucene/node/Person_exact/_1.fdx +0 -0
  14. data/lib/db/index/lucene/node/Person_exact/_1.fnm +1 -0
  15. data/lib/db/index/lucene/node/Person_exact/_1.frq +0 -0
  16. data/lib/db/index/lucene/node/Person_exact/_1.nrm +1 -0
  17. data/lib/db/index/lucene/node/Person_exact/_1.prx +0 -0
  18. data/lib/db/index/lucene/node/Person_exact/_1.tii +0 -0
  19. data/lib/db/index/lucene/node/Person_exact/_1.tis +0 -0
  20. data/lib/db/index/lucene/node/Person_exact/_2.fdt +0 -0
  21. data/lib/db/index/lucene/node/Person_exact/_2.fdx +0 -0
  22. data/lib/db/index/lucene/node/Person_exact/_2.fnm +1 -0
  23. data/lib/db/index/lucene/node/Person_exact/_2.frq +0 -0
  24. data/lib/db/index/lucene/node/Person_exact/_2.nrm +1 -0
  25. data/lib/db/index/lucene/node/Person_exact/_2.prx +0 -0
  26. data/lib/db/index/lucene/node/Person_exact/_2.tii +0 -0
  27. data/lib/db/index/lucene/node/Person_exact/_2.tis +0 -0
  28. data/lib/db/index/lucene/node/Person_exact/segments.gen +0 -0
  29. data/lib/db/index/lucene/node/Person_exact/segments_3 +0 -0
  30. data/lib/db/index/lucene-store.db +0 -0
  31. data/lib/db/index/lucene.log.active +0 -0
  32. data/lib/db/index.db +0 -0
  33. data/lib/db/messages.log +826 -0
  34. data/lib/db/neostore +0 -0
  35. data/lib/db/neostore.id +0 -0
  36. data/lib/db/neostore.nodestore.db +0 -0
  37. data/lib/db/neostore.nodestore.db.id +0 -0
  38. data/lib/db/neostore.propertystore.db +0 -0
  39. data/lib/db/neostore.propertystore.db.arrays +0 -0
  40. data/lib/db/neostore.propertystore.db.arrays.id +0 -0
  41. data/lib/db/neostore.propertystore.db.id +0 -0
  42. data/lib/db/neostore.propertystore.db.index +0 -0
  43. data/lib/db/neostore.propertystore.db.index.id +0 -0
  44. data/lib/db/neostore.propertystore.db.index.keys +0 -0
  45. data/lib/db/neostore.propertystore.db.index.keys.id +0 -0
  46. data/lib/db/neostore.propertystore.db.strings +0 -0
  47. data/lib/db/neostore.propertystore.db.strings.id +0 -0
  48. data/lib/db/neostore.relationshipstore.db +0 -0
  49. data/lib/db/neostore.relationshipstore.db.id +0 -0
  50. data/lib/db/neostore.relationshiptypestore.db +0 -0
  51. data/lib/db/neostore.relationshiptypestore.db.id +0 -0
  52. data/lib/db/neostore.relationshiptypestore.db.names +0 -0
  53. data/lib/db/neostore.relationshiptypestore.db.names.id +0 -0
  54. data/lib/db/nioneo_logical.log.active +0 -0
  55. data/lib/db/tm_tx_log.1 +0 -0
  56. data/lib/example.rb +34 -0
  57. data/lib/neo4j/identity_map.rb +109 -0
  58. data/lib/neo4j/node_mixin.rb +74 -0
  59. data/lib/neo4j/relationship_mixin.rb +62 -0
  60. data/lib/neo4j/type_converters/type_converters.rb +333 -0
  61. data/lib/neo4j-wrapper/class_methods.rb +27 -0
  62. data/lib/neo4j-wrapper/find.rb +65 -0
  63. data/lib/neo4j-wrapper/has_n/class_methods.rb +131 -0
  64. data/lib/neo4j-wrapper/has_n/decl_rel.rb +261 -0
  65. data/lib/neo4j-wrapper/has_n/instance_methods.rb +12 -0
  66. data/lib/neo4j-wrapper/has_n/nodes.rb +83 -0
  67. data/lib/neo4j-wrapper/node_mixin/class_methods.rb +53 -0
  68. data/lib/neo4j-wrapper/node_mixin/delegates.rb +140 -0
  69. data/lib/neo4j-wrapper/node_mixin/initialize.rb +43 -0
  70. data/lib/neo4j-wrapper/properties/class_methods.rb +150 -0
  71. data/lib/neo4j-wrapper/relationship_mixin/class_methods.rb +30 -0
  72. data/lib/neo4j-wrapper/relationship_mixin/delegates.rb +110 -0
  73. data/lib/neo4j-wrapper/relationship_mixin/initialize.rb +35 -0
  74. data/lib/neo4j-wrapper/rule/class_methods.rb +204 -0
  75. data/lib/neo4j-wrapper/rule/event_listener.rb +66 -0
  76. data/lib/neo4j-wrapper/rule/functions/count.rb +45 -0
  77. data/lib/neo4j-wrapper/rule/functions/function.rb +76 -0
  78. data/lib/neo4j-wrapper/rule/functions/sum.rb +31 -0
  79. data/lib/neo4j-wrapper/rule/instance_methods.rb +16 -0
  80. data/lib/neo4j-wrapper/rule/neo4j_core_ext/traverser.rb +29 -0
  81. data/lib/neo4j-wrapper/rule/rule.rb +134 -0
  82. data/lib/neo4j-wrapper/rule/rule_node.rb +205 -0
  83. data/lib/neo4j-wrapper/version.rb +5 -0
  84. data/lib/neo4j-wrapper/wrapper.rb +38 -0
  85. data/lib/neo4j-wrapper.rb +35 -0
  86. data/lib/test.rb +61 -0
  87. data/neo4j-wrapper.gemspec +31 -0
  88. metadata +162 -0
@@ -0,0 +1,140 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module NodeMixin
4
+ module Delegates
5
+ class << self
6
+ private
7
+ # @macro [new] node.delegate
8
+ # @method $1(*args, &block)
9
+ # Delegates to {http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/$2#$1-instance_method Neo4j::Core::Node#$1} using the <tt>_java_entity</tt> instance with the supplied parameters.
10
+ # @see Neo4j::NodeMixin#_java_entity
11
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/$2#$1-instance_method Neo4j::Core::Node#$1
12
+ def delegate(*args)
13
+ method_name = args.first
14
+ class_eval(<<-EOM, __FILE__, __LINE__)
15
+ def #{method_name}(*args, &block)
16
+ _java_entity.send(:#{method_name}, *args, &block)
17
+ end
18
+ EOM
19
+ end
20
+ end
21
+
22
+
23
+ # Methods included from Core::Property
24
+ # [], #[]=, #neo_id, #property?, #props, #update
25
+
26
+ # @macro node.delegate
27
+ delegate :[]=, 'Property'
28
+
29
+ # @macro node.delegate
30
+ delegate :[], 'Property'
31
+
32
+ # @macro node.delegate
33
+ delegate :property?, 'Property'
34
+
35
+ # @macro node.delegate
36
+ delegate :props, 'Property'
37
+
38
+ # @macro node.delegate
39
+ delegate :update, 'Property'
40
+
41
+ # @macro node.delegate
42
+ delegate :neo_id, 'Property'
43
+
44
+
45
+ #Methods included from Core::Rels
46
+ # _node, #_nodes, #_rel, #_rels, #node, #nodes, #rel, #rel?, #rels
47
+
48
+ # @macro node.delegate
49
+ delegate :node, 'Rels'
50
+
51
+ # @macro node.delegate
52
+ delegate :_node, 'Rels'
53
+
54
+ # @macro node.delegate
55
+ delegate :nodes, 'Rels'
56
+
57
+ # @macro node.delegate
58
+ delegate :_nodes, 'Rels'
59
+
60
+ # @macro node.delegate
61
+ delegate :rel, 'Rels'
62
+
63
+ # @macro node.delegate
64
+ delegate :_rel, 'Rels'
65
+
66
+ # @macro node.delegate
67
+ delegate :rels, 'Rels'
68
+
69
+ # @macro node.delegate
70
+ delegate :_rels, 'Rels'
71
+
72
+ # @macro node.delegate
73
+ delegate :rel?, 'Rels'
74
+
75
+
76
+ # Methods included from Core::Traversal
77
+ # both, #eval_paths, #expand, #incoming, #outgoing, #unique
78
+
79
+ # @macro node.delegate
80
+ delegate :both, 'Traversal'
81
+
82
+ # @macro node.delegate
83
+ delegate :eval_paths, 'Traversal'
84
+
85
+ # @macro node.delegate
86
+ delegate :expand, 'Traversal'
87
+
88
+ # @macro node.delegate
89
+ delegate :incoming, 'Traversal'
90
+
91
+ # @macro node.delegate
92
+ delegate :outgoing, 'Traversal'
93
+
94
+ # @macro node.delegate
95
+ delegate :unique, 'Traversal'
96
+
97
+
98
+ # Methods included from Core::Node
99
+ # #del, #exist?
100
+
101
+ # @macro node.delegate
102
+ delegate :del, 'Node'
103
+
104
+ # @macro node.delegate
105
+ delegate :exist?, 'Node'
106
+
107
+ # Methods included from Core::Property::Java
108
+ #get_property, #graph_database, #property_keys, #remove_property, #set_property
109
+
110
+ # @macro node.delegate
111
+ delegate :get_property, 'Property/Java'
112
+
113
+ # @macro node.delegate
114
+ delegate :set_property, 'Property/Java'
115
+
116
+ # @macro node.delegate
117
+ delegate :property_keys, 'Property/Java'
118
+
119
+ # @macro node.delegate
120
+ delegate :remove_property, 'Property/Java'
121
+
122
+ # Methods included from Core::Equal
123
+ #==, #eql?, #equal?
124
+
125
+ # @macro node.delegate
126
+ delegate :equal?, 'Equal'
127
+
128
+ # @macro node.delegate
129
+ delegate :eql?, 'Equal'
130
+
131
+
132
+ # @macro node.delegate
133
+ delegate :==
134
+
135
+ # @macro node.delegate
136
+ delegate :getId
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,43 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module NodeMixin
4
+ module Initialize
5
+
6
+ # Init this node with the specified java neo node
7
+ # @param [Neo4j::Node] java_node the node this instance wraps
8
+ def init_on_load(java_node)
9
+ @_java_node = java_node
10
+ end
11
+
12
+
13
+ # Creates a new node and initialize with given properties.
14
+ # You can override this to provide your own initialization.
15
+ #
16
+ # @param [Object, :each_pair] args if the first item in the list implements :each_pair then it will be initialize with those properties
17
+ def init_on_create(*args)
18
+ _java_entity[:_classname] = self.class.to_s
19
+ if args[0].respond_to?(:each_pair)
20
+ args[0].each_pair { |k, v| respond_to?("#{k}=") ? self.send("#{k}=", v) : _java_entity[k] = v }
21
+ end
22
+ end
23
+
24
+ # @return [Neo4j::Node] Returns the org.neo4j.graphdb.Node wrapped object
25
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Node
26
+ def _java_node
27
+ @_java_node
28
+ end
29
+
30
+ # Implements the Neo4j::Node#wrapper and Neo4j::Relationship#wrapper method
31
+ # so that we don't have to care if the node is wrapped or not.
32
+ # @return self
33
+ def wrapper
34
+ self
35
+ end
36
+
37
+ alias_method :_java_entity, :_java_node
38
+
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,150 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module Property
4
+
5
+ module ClassMethods
6
+
7
+ # @return [Hash] a hash of all properties and its configuration defined by property class method
8
+ def _decl_props
9
+ @_decl_props ||= {}
10
+ end
11
+
12
+ # make sure the inherited classes inherit the <tt>_decl_props</tt> hash
13
+ def inherited(klass)
14
+ klass.instance_variable_set(:@_decl_props, _decl_props.clone)
15
+ super
16
+ end
17
+
18
+ # Generates accessor method and sets configuration for Neo4j node properties.
19
+ # The generated accessor creates a wrapper around the <tt>#[]</tt> and <tt>#[]=</tt> operators and
20
+ # support conversion of values before it is read or written to the database, using the <tt>:type</tt> config parameter.
21
+ # If a property is set to nil the property will be removed (just like the <tt>#[]=</tt>accessor])
22
+ # A lucene index can also be specified, using the <tt>:index</tt> config parameter.
23
+ # If you want to add index on a none declared property you can (still) use the <tt>index</tt> class method, see
24
+ # {Neo4j::Core::Index::Indexer}[http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/Index/Indexer]
25
+ #
26
+ # === :type
27
+ # A property can be of any primitive type (Boolean, String, Fixnum, Float)
28
+ # and does not even have to be the same. Arrays of primitive types is also supported. Array values must
29
+ # be of the same type and are mutable, e.g. you have to create a new array if you want to change one value.
30
+ # To make sure a property is always stored as the same type you can use the TypeConverter, which is specified using
31
+ # either the <tt>:type</tt> or the <tt>:converter</tt> parameter. This is also important when indexing, e.g finding a
32
+ # property which has been declared as a Fixnum but queried as a String will not work.
33
+ #
34
+ # === :converter
35
+ # You can implement your own converter, see Neo4j::TypeConverters.
36
+ # You can write your own converter by writing a class that respond to <tt>:index_as</tt>, <tt>:to_ruby</tt> and
37
+ # <tt>:to_java</tt>.
38
+ #
39
+ # === :index
40
+ # If a <tt>:index</tt> is specified the property will be automatically indexed.
41
+ # By default, there are two different indices available: <tt>:fulltext</tt> and <tt>:exact</tt>
42
+ # If not specified in a query it will use by default an <tt>:exact</tt> index.
43
+ # Notice, that you can't combine a fulltext and exact lucene query in the same query.
44
+ # If you are using fulltext index you <b>must</b> specify the type parameter in the find method
45
+ # (<tt>:exact</tt> is default).
46
+ # Also, if you want to sort or do range query make sure use the same query parameters as the declared type
47
+ # For example if you index with <tt>property :age, :index => :exact, :type => Fixnum)</tt> then you must query
48
+ # with age parameter being a fixnum, see examples below.
49
+ #
50
+ # @example a property with an index
51
+ #
52
+ # class Foo
53
+ # include Neo4j::NodeMixin
54
+ # property :description, :index => :fulltext
55
+ # end
56
+ #
57
+ # @example Lucene Query
58
+ # Foo.find("description: bla", :type => :fulltext)
59
+ # Foo.find({:description => "bla"}, {:type => :fulltext})
60
+ #
61
+ # @example Lucene Query with a Fixnum index
62
+ # Foo.find(:age => 35)
63
+ # Foo.find(:age => (32..37))
64
+ # Foo.find("age: 35") # does not work !
65
+ #
66
+ # === More Examples
67
+ #
68
+ # @example declare a property
69
+ # class Foo
70
+ # include Neo4j::NodeMixin
71
+ # property :age
72
+ # end
73
+ #
74
+ # @example use a declared property
75
+ # foo = Foo.new
76
+ # foo.age = "hej" # first set it to string
77
+ # foo.age = 42 # change it to a Fixnum
78
+ #
79
+ # However, you can specify an type for the index, see Neo4j::Index::Indexer#index
80
+ #
81
+ # @example conversion of none primitive types
82
+ #
83
+ # class Foo
84
+ # include Neo4j::NodeMixin
85
+ # property :since, :type => DateTime # will be converted into a fixnum
86
+ # end
87
+ #
88
+ # @example declare several properties in one line
89
+ #
90
+ # class Foo
91
+ # include Neo4j::NodeMixin
92
+ # property :name, :description, :type => String, :index => :exact
93
+ # end
94
+ #
95
+ # @param [Symbol, Hash] props one or more properties and optionally last a Hash for options
96
+ # @see Neo4j::TypeConverters
97
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/Index/LuceneQuery Neo4j::Core::Index::LuceneQuery
98
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/Index/Indexer Neo4j::Core::Index::Indexer
99
+ def property(*props)
100
+ options = props.last.kind_of?(Hash) ? props.pop : {}
101
+
102
+ props.uniq.each do |prop|
103
+ pname = prop.to_sym
104
+ _decl_props[pname] ||= {}
105
+ options.each { |key, value| _decl_props[pname][key] = value }
106
+
107
+ converter = options[:converter] || Neo4j::TypeConverters.converter(_decl_props[pname][:type])
108
+ _decl_props[pname][:converter] = converter
109
+
110
+ if options.include?(:index)
111
+ index(pname, :type => options[:index], :field_type => converter.index_as)
112
+ end
113
+
114
+ define_method(pname) do
115
+ self.class._converter(pname).to_ruby(self[pname])
116
+ end
117
+
118
+ name = (pname.to_s() +"=").to_sym
119
+ define_method(name) do |value|
120
+ self[pname] = self.class._converter(pname).to_java(value)
121
+ end
122
+ end
123
+ end
124
+
125
+
126
+ # @param [String, Symbol] prop_name the name of the property
127
+ # @return [#to_java, #to_ruby, #field_type] a converter for the given property name
128
+ # @note if the property has not been defined it will return the DefaultConverter
129
+ # @see Neo4j::TypeConverters::DefaultConverter
130
+ def _converter(prop_name)
131
+ prop_conf = _decl_props[prop_name.to_sym]
132
+ Neo4j::TypeConverters::DefaultConverter unless prop_conf
133
+ prop_conf[:converter]
134
+ end
135
+
136
+ # Returns true if the given property name has been defined with the class
137
+ # method property or properties.
138
+ #
139
+ # Notice that the node may have properties that has not been declared.
140
+ # It is always possible to set an undeclared property on a node.
141
+ #
142
+ # @return [true, false]
143
+ def property?(prop_name)
144
+ return false if _decl_props[prop_name.to_sym].nil?
145
+ !_decl_props[prop_name.to_sym].nil?
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,30 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module RelationshipMixin
4
+ module ClassMethods
5
+
6
+ # Creates a relationship between given nodes.
7
+ #
8
+ # You can use two callback method to initialize the relationship
9
+ # init_on_load:: this method is called when the relationship is loaded from the database
10
+ # init_on_create:: called when the relationship is created, will be provided with the same argument as the new method
11
+ #
12
+ # @param [String, Symbol] type the type of the relationships
13
+ # @param [Neo4j::Node, Neo4j::NodeMixin] from_node create relationship from this node
14
+ # @param [Neo4j::Node, Neo4j::NodeMixin] to_node create relationship to this node
15
+ # @param [Hash] props optional hash of properties to initialize the create relationship with
16
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Relationship Neo4j::Relationship
17
+ def new(type, from_node, to_node, *props)
18
+ rel = Neo4j::Relationship.create(type, from_node, to_node)
19
+ wrapped_rel = super()
20
+ Neo4j::IdentityMap.add(rel, wrapped_rel)
21
+ wrapped_rel.init_on_load(rel)
22
+ wrapped_rel.init_on_create(type, from_node, to_node, *props)
23
+ wrapped_rel
24
+ end
25
+
26
+ alias_method :create, :new
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,110 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module RelationshipMixin
4
+ module Delegates
5
+
6
+ class << self
7
+ private
8
+ # @macro [new] node.delegate
9
+ # @method $1(*args, &block)
10
+ # Delegates to {http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/$2#$1-instance_method Neo4j::Core::Relationship#$1} using the <tt>_java_entity</tt> instance with the supplied parameters.
11
+ # @see Neo4j::Relationship#_java_entity
12
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Core/$2#$1-instance_method Neo4j::Relationship#$1
13
+ def delegate(*args)
14
+ method_name = args.first
15
+ class_eval(<<-EOM, __FILE__, __LINE__)
16
+ def #{method_name}(*args, &block)
17
+ _java_entity.send(:#{method_name}, *args, &block)
18
+ end
19
+ EOM
20
+ end
21
+ end
22
+
23
+
24
+ # Methods included from Core::Property
25
+ # [], #[]=, #neo_id, #property?, #props, #update
26
+
27
+ # @macro node.delegate
28
+ delegate :[]=, 'Property'
29
+
30
+ # @macro node.delegate
31
+ delegate :[], 'Property'
32
+
33
+ # @macro node.delegate
34
+ delegate :property?, 'Property'
35
+
36
+ # @macro node.delegate
37
+ delegate :props, 'Property'
38
+
39
+ # @macro node.delegate
40
+ delegate :update, 'Property'
41
+
42
+ # @macro node.delegate
43
+ delegate :neo_id, 'Property'
44
+
45
+ # Methods included from Core::Relationship
46
+
47
+ # @macro node.delegate
48
+ delegate :_end_node, 'Relationship'
49
+
50
+ # @macro node.delegate
51
+ delegate :end_node, 'Relationship'
52
+
53
+
54
+ # @macro node.delegate
55
+ delegate :_start_node, 'Relationship'
56
+
57
+ # @macro node.delegate
58
+ delegate :end_node, 'Relationship'
59
+
60
+ # @macro node.delegate
61
+ delegate :other_node, 'Relationship'
62
+
63
+ # @macro node.delegate
64
+ delegate :_other_node, 'Relationship'
65
+
66
+ # @macro node.delegate
67
+ delegate :del, 'Relationship'
68
+
69
+ # @macro node.delegate
70
+ delegate :exist?, 'Relationship'
71
+
72
+ # @macro node.delegate
73
+ delegate :rel_type, 'Relationship'
74
+
75
+ # Methods included from Core::Property::Java
76
+ #get_property, #graph_database, #property_keys, #remove_property, #set_property
77
+
78
+ # @macro node.delegate
79
+ delegate :get_property, 'Property/Java'
80
+
81
+ # @macro node.delegate
82
+ delegate :set_property, 'Property/Java'
83
+
84
+ # @macro node.delegate
85
+ delegate :property_keys, 'Property/Java'
86
+
87
+ # @macro node.delegate
88
+ delegate :remove_property, 'Property/Java'
89
+
90
+ # Methods included from Core::Equal
91
+ #==, #eql?, #equal?
92
+
93
+ # @macro node.delegate
94
+ delegate :equal?, 'Equal'
95
+
96
+ # @macro node.delegate
97
+ delegate :eql?, 'Equal'
98
+
99
+
100
+ # @macro node.delegate
101
+ delegate :==
102
+
103
+ # @macro node.delegate
104
+ delegate :getId
105
+ end
106
+
107
+ end
108
+ end
109
+ end
110
+
@@ -0,0 +1,35 @@
1
+ module Neo4j
2
+ module Wrapper
3
+ module RelationshipMixin
4
+ module Initialize
5
+
6
+ # Init this node with the specified java neo4j relationship.
7
+ def init_on_load(java_rel)
8
+ @_java_rel = java_rel
9
+ end
10
+
11
+
12
+ # Creates a new node and initialize with given properties.
13
+ # You can override this to provide your own initialization.
14
+ #
15
+ # @param (see Neo4j::Wrapper::RelationshipMixin::ClassMethods#new)
16
+ def init_on_create(rel_type, from_node, to_node, *props) # :nodoc:
17
+ _java_entity[:_classname] = self.class.to_s
18
+ if props.first.respond_to?(:each_pair)
19
+ props.first.each_pair { |k, v| respond_to?("#{k}=") ? self.send("#{k}=", v) : @_java_rel[k] = v }
20
+ end
21
+ end
22
+
23
+ # @returns [Neo4j::Relationship] the wrapped relationship object
24
+ # @see http://rdoc.info/github/andreasronge/neo4j-core/master/Neo4j/Relationship Neo4j::Relationship
25
+ def _java_rel
26
+ @_java_rel
27
+ end
28
+
29
+ alias_method :_java_entity, :_java_rel
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+ end