👋 Hey folks! I was hoping you might indulge me in a trivial, nattering design question. I've been working with Neo4j.rb to build out a model for a Post object, and recently turned to the enum property type as a way of expressing its publication state, comme ça:
class Post
include Neo4j::ActiveNode
include Neo4j::Timestamps
enum visibility: %i[drafting pending previewing published], _suffix: true
end
The instance gets a visibility attribute, along with the suffixed bang and predicate methods---so far so good.
But I ran into a little surprise when I went to add a class method:
class Post
def self.first_page
published_visibility # Blep!
.order(published_at: :desc)
.limit(10)
end
end
published_visibility turns out not to exist on the class! The instance methods get attached with prefixes and suffixes, but the class methods are added ungarnished:
This feels a hair inconsistent in the abstract, but it's giving me some practical trouble as well: I was hoping to use the enum to persist state for AASM, but its class methods and AASM's are stepping on one another's toes. (I'm not even sure at a cursory glance which are clobbering which.)
I'd be happy to try my hand at a PR bringing the class- and instance-level naming conventions in line, but figured it couldn't hurt to ask in advance whether this was an intentional design decision and/or how attached to it the current maintainers are.
👋 Hey folks! I was hoping you might indulge me in a trivial, nattering design question. I've been working with Neo4j.rb to build out a model for a
Post
object, and recently turned to theenum
property type as a way of expressing its publication state, comme ça:The instance gets a
visibility
attribute, along with the suffixed bang and predicate methods---so far so good.But I ran into a little surprise when I went to add a class method:
published_visibility
turns out not to exist on the class! The instance methods get attached with prefixes and suffixes, but the class methods are added ungarnished:https://github.com/neo4jrb/neo4j/blob/5d02143cb41f5046ea1de69a10e230d7360dc1c8/lib/neo4j/active_node/enum.rb#L19-L23
This feels a hair inconsistent in the abstract, but it's giving me some practical trouble as well: I was hoping to use the enum to persist state for AASM, but its class methods and AASM's are stepping on one another's toes. (I'm not even sure at a cursory glance which are clobbering which.)
I'd be happy to try my hand at a PR bringing the class- and instance-level naming conventions in line, but figured it couldn't hurt to ask in advance whether this was an intentional design decision and/or how attached to it the current maintainers are.
Thanks in advance for your thoughts! ✨
Runtime information:
Neo4j database version:
neo4j
gem version: 9.4.0neo4j-core
gem version: 9.0.0