module Neomirror::Node::ClassMethods
Attributes
neo_primary_key[W]
Public Instance Methods
mirror_neo_node(options = {}, &block)
click to toggle source
# File lib/neomirror/node.rb, line 17 def mirror_neo_node(options = {}, &block) raise "Node mirror is already defined. Reflection model into more than one node is not supported. Create an issue if you need such functionality." if @neo_mirror @neo_mirror = options @neo_mirror[:label] ||= self.name.gsub(/^.*::/, '').to_sym # demodulize @neo_mirror[:properties] = ::Neomirror::PropertyCollector.new(&block).properties if block_given? ::Neomirror.neo.execute_query("CREATE CONSTRAINT ON (n:#{@neo_mirror[:label]}) ASSERT n.id IS UNIQUE") @neo_mirror end
neo_mirror()
click to toggle source
# File lib/neomirror/node.rb, line 10 def neo_mirror @neo_mirror ||= begin return nil unless a = self.ancestors.drop(1).find { |c| c.respond_to?(:neo_mirror) && c.neo_mirror } a.neo_mirror end end
neo_primary_key()
click to toggle source
# File lib/neomirror/node.rb, line 26 def neo_primary_key @neo_primary_key ||= self.respond_to?(:primary_key) ? self.__send__(:primary_key) : :id end