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

Already on GitHub? Sign in to your account

Syntactical sugar.. #152

pehrlich opened this Issue Feb 2, 2012 · 6 comments


None yet
4 participants

pehrlich commented Feb 2, 2012

..would ease the learning curve!

For example, I would argue:

  • Every enum with a #first should have a #last
  • just as there are rels and _rels, there should be _goals_rels, and goals_rels. (currently, only the ruby variant exists)
  • noun-verb agreement would be expected as well: goal_rels
  • rels and _rels should not take different arguments. (type, and dir & type, respectively)
  • it is not clear that :type stands for the Ruby relationship class, symbolized and lower cased.
  • Nor is it clear how one would use the rels or _rels method to look for rels from a named association! Indeed, the source itself uses "type" differently: @rel_type = "#{@target_class}##{@method_id}", which is misleading.

There are a few things that I can't tell if they are bugs or my own misunderstanding:

 > u._rels.first.class
 => Neo4j::Relationship #ok
 > u.rels.first.to_java.class
ArgumentError: wrong number of arguments (0 for 2) #not ok

There were some other issues I ran into, but I'll spare you the details.

Is there any way to get debugging insight on these "typeless classes"? It appears they are sometimes Java and sometimes Ruby, but I'm not certain.

> u.rels(:action).each {|r| p r.class.name}
 => [#<#<Class:0x18185576>:0x2b35b547>, #<#<Class:0x18185576>:0x53105e7a>] 
 u.rels(:action).each {|r| p r.inspect }
 => [#<#<Class:0x18185576>:0x2b35b547>, #<#<Class:0x18185576>:0x53105e7a>]

Edit: What if for 2.0, we added a method that for any DSL object, a method could be called listing the chainable methods?


andreasronge commented Feb 2, 2012

Great input. The "typeless classes" are really Java object, but I've implemented the class method so that it looks like a Ruby object :-)
What would be the purpose of the method on the DSL object returning the list of chainable methods ?


pehrlich commented Feb 2, 2012

Glad to hear these ideas may be useful

I'm confused by your above though--
if rels returns a ruby wrapper, with working class name, as above, couldn't that be used instead of the word Class and two memory locaitons? Is that syntax indicating a ruby wrapper around a java object? Could the real java class name "org.neo4j.graphdb.Relationship" be used?

Its been a few times when I get back "Class" objects and have no idea what they are or what they can do. A node? a rel? A java node or java rel? A dsl for a node for a rel? Which dsl? --its not always obvious. Like the ruby method :instance_methods, one could have :dsl_methods to learn where to go from here.


andreasronge commented Feb 2, 2012

Only if the property _classname exist there could be a Ruby class wrapper around the java object (which will automatically be loaded unless using a _method). If there is no _classname property it will return the java object which pretends it is a Ruby object (by impl. the class method returning Neo4j::Node).
But you can always call instance_methods on the java classes and the dsl objects.


pehrlich commented Feb 2, 2012

Can you?

 > x = u._rels.find_all{|r| r[:latest] == true }
 => [#<#<Class:0x182660ad>:0x37fead5c>, #<#<Class:0x182660ad>:0x2a6e1eba>, #<#<Class:0x182660ad>:0x23a35b19>, #<#<Class:0x182660ad>:0x39b1d896>] 
jruby-1.6.5 :043 > x.first
 => #<#<Class:0x182660ad>:0x37fead5c> 
jruby-1.6.5 :044 > x.first.instance_methods
NoMethodError: undefined method `instance_methods' for #<#<Class:0x182660ad>:0x37fead5c>

This doesn't seem to be an issue specific to the java nodes though:

NoMethodError: undefined method `instance_methods' for #<Action:0x3cf55d7f>

saterus commented Jul 3, 2013

Is there anything to be done for this issue? It seems like it is mostly a product of having a multi-layered API that has the ability to drop down into Java.


subvertallchris commented Sep 21, 2014

Closing this. Very old, already implemented in the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment