Module: Neomirror::Node::ClassMethods
- Defined in:
- lib/neomirror/node.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#neo_primary_key ⇒ Object
26 27 28 |
# 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 |
Instance Method Details
#mirror_neo_node(options = {}, &block) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/neomirror/node.rb', line 17 def mirror_neo_node( = {}, &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 = @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 ⇒ Object
10 11 12 13 14 15 |
# 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 |