Module: Pacer::VertexMixin
- Included in:
- DexVertex, Neo4jVertex, TinkerVertex, VertexWrapper
- Defined in:
- lib/pacer/graph/vertex_mixin.rb
Overview
This module is mixed into the raw Blueprints Vertex class from any graph implementation.
Adds more convenient/rubyish methods and adds support for extensions to some methods where needed.
Instance Method Summary (collapse)
-
- (Pacer::EdgeWrapper) add_extensions(exts)
Add extensions to this vertex.
-
- (Pacer::VertexMixin) clone_into(target_graph, opts = nil) {|v| ... }
Copies including the vertex id unless a vertex with that id already exists.
-
- (Pacer::VertexMixin) copy_into(target_graph) {|v| ... }
Make a new copy of the element with the next available vertex id.
-
- (Object) delete!
Deletes the vertex from its graph along with all related edges.
-
- (String) display_name
Returns the display name of the vertex.
-
- (String) inspect
Returns a human-readable representation of the vertex using the standard ruby console representation of an instantiated object.
Instance Method Details
- (Pacer::EdgeWrapper) add_extensions(exts)
Add extensions to this vertex.
If any extension has a Vertex module within it, this vertex will be extended with the extension's Vertex module.
18 19 20 21 22 23 24 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 18 def add_extensions(exts) if exts.any? VertexWrapper.wrap(self, exts) else self end end |
- (Pacer::VertexMixin) clone_into(target_graph, opts = nil) {|v| ... }
Copies including the vertex id unless a vertex with that id already exists.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 50 def clone_into(target_graph, opts = nil) v_idx = target_graph.index_name("tmp:v:#{graph.to_s}", :vertex, :create => true) v = target_graph.vertex(element_id) || v_idx.get('id', element_id).first unless v v = target_graph.create_vertex element_id, properties v_idx.put('id', element_id, v) yield v if block_given? end v end |
- (Pacer::VertexMixin) copy_into(target_graph) {|v| ... }
Make a new copy of the element with the next available vertex id.
66 67 68 69 70 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 66 def copy_into(target_graph) v = target_graph.create_vertex properties yield v if block_given? v end |
- (Object) delete!
Deletes the vertex from its graph along with all related edges.
40 41 42 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 40 def delete! graph.remove_vertex element end |
- (String) display_name
Returns the display name of the vertex.
35 36 37 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 35 def display_name graph.vertex_name.call self if graph and graph.vertex_name end |
- (String) inspect
Returns a human-readable representation of the vertex using the standard ruby console representation of an instantiated object.
29 30 31 |
# File 'lib/pacer/graph/vertex_mixin.rb', line 29 def inspect "#<#{ ["V[#{element_id}]", display_name].compact.join(' ') }>" end |