lib/grumlin/repository/instance_methods.rb in grumlin-1.0.4 vs lib/grumlin/repository/instance_methods.rb in grumlin-1.1.0

- old
+ new

@@ -56,20 +56,20 @@ start.V(from).outE(label).where(__.inV.hasId(to)).limit(1).drop.iterate end def add_vertex(label, id = nil, start: g, **properties) id ||= properties[T.id] - properties = except(properties, T.id) + properties = properties.except(T.id) t = start.addV(label) t = t.props(T.id => id) unless id.nil? t.props(**properties).next end def add_edge(label, id = nil, from:, to:, start: g, **properties) id ||= properties[T.id] - properties = except(properties, T.label) + properties = properties.except(T.label) properties[T.id] = id start.addE(label).from(__.V(from)).to(__.V(to)).props(**properties).next end @@ -130,26 +130,16 @@ DEFAULT_ERROR_HANDLING_STRATEGY end.apply!(&block) end def with_upsert_retry(retry_params, &block) - retry_params = UPSERT_RETRY_PARAMS.merge((retry_params)) + retry_params = UPSERT_RETRY_PARAMS.merge(retry_params) Retryable.retryable(**retry_params, &block) end - # A polyfill for Hash#except for ruby 2.x environments without ActiveSupport - # TODO: delete and use native Hash#except after ruby 2.7 is deprecated. - def except(hash, *keys) - return hash.except(*keys) if hash.respond_to?(:except) - - hash.each_with_object({}) do |(k, v), res| - res[k] = v unless keys.include?(k) - end - end - def cleanup_properties(create_properties, update_properties, *props_to_cleanup) props_to_cleanup = [T.id, T.label] if props_to_cleanup.empty? [create_properties, update_properties].map do |props| - except(props, props_to_cleanup) + props.except(props_to_cleanup) end end end