Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major refactor of Rest class #58

Merged
merged 22 commits into from
Sep 8, 2012
Merged

Conversation

rdvdijk
Copy link
Collaborator

@rdvdijk rdvdijk commented Sep 8, 2012

This is a major refactoring of the Rest class, which is currently too big and complex.

I've split up the Rest class into multiple classes and modules:

lib/neography/connection.rb
lib/neography/rest/batch.rb
lib/neography/rest/clean.rb
lib/neography/rest/cypher.rb
lib/neography/rest/gremlin.rb
lib/neography/rest/helpers.rb
lib/neography/rest/node_auto_indexes.rb
lib/neography/rest/node_indexes.rb
lib/neography/rest/node_paths.rb
lib/neography/rest/node_properties.rb
lib/neography/rest/node_relationships.rb
lib/neography/rest/node_traversal.rb
lib/neography/rest/nodes.rb
lib/neography/rest/paths.rb
lib/neography/rest/relationship_auto_indexes.rb
lib/neography/rest/relationship_indexes.rb
lib/neography/rest/relationship_properties.rb
lib/neography/rest/relationships.rb

The Rest class now does calls to all of these smaller classes. The smaller classes clearly define the REST urls and can be called using helper methods. Here is an example of the Relationships class. It defines one path base with value /relationship/:id, which is expanded with base_path(:id => "42") to the path /relationship/42:

module Neography
  class Rest
    class Relationships
      include Neography::Rest::Paths
      include Neography::Rest::Helpers

      add_path :base,   "/relationship/:id"

      def initialize(connection)
        @connection = connection
      end

      def get(id)
        @connection.get(base_path(:id => get_id(id)))
      end

      def delete(id)
        @connection.delete(base_path(:id => get_id(id)))
      end

    end
  end
end

I've also added unit tests to all of these classes and modules. The only class that now needs unit tests is the (still complex) Batch class.

All existing integration tests pass.

@rdvdijk
Copy link
Collaborator Author

rdvdijk commented Sep 8, 2012

I have also cleaned up some code and fixed the URL escaping bug for spaces and slashes that I mentioned in my previous pull request.

@maxdemarzi
Copy link
Owner

Roel,

That is monster refactor that was badly needed. I hope you are doing something crazy with Neo4j.

Thanks for your awesome work,
Max

maxdemarzi added a commit that referenced this pull request Sep 8, 2012
Major refactor of Rest class
@maxdemarzi maxdemarzi merged commit 92b0097 into maxdemarzi:master Sep 8, 2012
willkessler pushed a commit to willkessler/neography that referenced this pull request Apr 21, 2014
adding select argument, making include :none default, and adding a conne...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants