neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.39k stars 276 forks source link

Does not support ruby 3.0 positional arguments #1645

Closed Sag0ld closed 3 years ago

Sag0ld commented 3 years ago

In Ruby 3.0, positional arguments and keyword arguments will be separated.

In most cases, you can avoid the incompatibility by adding the double splat operator. It explicitly specifies passing keyword arguments instead of a Hash object. Likewise, you may add braces {} to explicitly pass a Hash object, instead of keyword arguments. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

Code example (inline, gist, or repo)

This is an exemple of where ruby-3.0 does not work with activegraph

  module Node
    # This mixin replace the original save method and performs validation before the save.
    module Validations
      extend ActiveSupport::Concern
      include ActiveGraph::Shared::Validations

[...]

        def validate_each(record, attribute, value)
          return unless found(record, attribute, value).exists?

          record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(value: value))
        end

[...]
      end
    end
  end
end

We must specified that option.exception will be more than one argument. The easy fix would be this

record.errors.add(attribute, :taken, **options.except(:case_sensitive, :scope).merge(value: value))

Question

Would it be possible to update the syntaxe for ruby 3.0 ? Thanks :D

Runtime information:

Neo4j database version: community-4.0.3 activegraph gem version: 10.0.2 neo4j-ruby-driver: 1.7.4

klobuczek commented 3 years ago

@Sag0ld Thank you. Yes, we should become compatible with ruby 3.0. But I would not like to do it case by case. The entire test suite should pass. One issue that is slowing down everything is the end of travis support for open source. So we need to find another CI platform.