neo4jrb / activegraph

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

ActiveNode inherit from a base class that is not a Node #1583

Open am17torres opened 4 years ago

am17torres commented 4 years ago

Is there a way to have an ActiveNode inherit from a base class that is not Node?

Additional information which could be helpful if relevant to your issue:

Code example (inline, gist, or repo)

Example:

app/models/base.rb

class Base
  include OpenApi::DSL
end

app/models/resource.rb

class Resource < Base
  include Neo4j::ActiveNode
  include Neo4j::Timestamps
end

When I try this I get an error:

`rescue in build_association': undefined method `associations' for Base:Class (Class#parent) (NoMethodError)

Runtime information:

Neo4j database version: 3.5.14 Community Edition neo4j gem version: 9.6.1 neo4j-core gem version: 9.0.0

klobuczek commented 4 years ago

@am17torres I totally agree with you. What you intend to do should be possible. Having said that I cannot imagine we will have the time to address that before we revisit the Label/Module vs. Label/Class concept. Right now it's impossible to express multiple labels on a node. But if you think there is a simple not too invasive fix to the problem you are more than welcome to create a PR against master. I'm sure your Base class is more complicated than in your example or otherwise, there would be no benefit of creating it and you could include the module directly.