README.md in grumlin-0.17.0 vs README.md in grumlin-0.18.0
- old
+ new
@@ -75,12 +75,11 @@
#### Shortcuts
**Shortcuts** is a way to share and organize gremlin code. They let developers define their own steps consisting of
sequences of standard gremlin steps, other shortcuts and even add new initially unsupported by Grumlin steps.
-Remember ActiveRecord scopes? Shortcuts are very similar. `Grumlin::Shortcuts#with_shortcuts` wraps a given object into
-a proxy object that simply proxies all methods existing in the wrapped object to it and handles shortcuts.
+Remember ActiveRecord scopes? Shortcuts are very similar.
**Important**: if a shortcut's name matches a name of a method defined on the wrapped object, this shortcut will be
be ignored because methods have higher priority. You cannot override supported by Grumlin steps with shortcuts,
`Grumlin::Shortcuts.shortcut` will raise an `ArgumentError`. Please carefully choose names for your shortcuts.
@@ -126,21 +125,22 @@
shortcuts_from AllShortcuts
# Wrapping a traversal
def red_triangles
- with_shortcuts(g).V.hasLabel(:triangle)
- .hasColor("red")
- .toList
+ g(self.class.shortcuts).V.hasLabel(:triangle)
+ .hasColor("red")
+ .toList
end
# Wrapping _
def something_else
- with_shortcuts(g).V.hasColor("red")
- .repeat(with_shortcuts(__)
- .out(:has)
- .hasColor("blue")).toList
+ g(self.class.shortcuts).V.hasColor("red")
+ .repeat(__(self.class.shortcuts))
+ .out(:has)
+ .hasColor("blue")
+ .toList
end
end
```
#### Grumlin::Repository
@@ -180,9 +180,17 @@
Each `return_mode` is mapped to a particular termination step:
- `:list` - `toList`
- `:single` - `next`
- `:none` - `iterate`
- `:traversal` - do not execute the query and return the traversal as is
+
+`Grumlin::Repository` also provides a set of generic CRUD operations:
+- `add_vertex(label, id = nil, **properties)`
+- `add_edge(label, id = nil, from:, to:, **properties)`
+- `drop_vertex(id)`
+- `drop_edge(id = nil, from: nil, to: nil, label: nil)`
+- `upsert_vertex(label, id, create_properties: {}, update_properties: {})`
+- `upsert_edge(label, from:, to:, create_properties: {}, update_properties: {})`
**Usage**
To execute the query defined in a query block one simply needs to call a method with the same name: