Module: ActiveGraph::Node::IdProperty

Extended by:
ActiveSupport::Concern
Includes:
Accessor
Included in:
ActiveGraph::Node
Defined in:
lib/active_graph/node/id_property.rb,
lib/active_graph/node/id_property/accessor.rb

Overview

This module makes it possible to use other IDs than the build it neo4j id (neo_id)

Examples:

using generated UUIDs

class Person
  include ActiveGraph::Node
  # creates a 'secret' neo4j property my_uuid which will be used as primary key
  id_property :my_uuid, auto: :uuid
end

using user defined ids

class Person
  include ActiveGraph::Node
  property :title
  validates :title, :presence => true
  id_property :title_id, on: :title_to_url

  def title_to_url
    self.title.urlize # uses https://github.com/cheef/string-urlize gem
  end
end

using already exsting ids that you don’t want a constraint added to

class Person
  include ActiveGraph::Node
  property :title
  validates :title, :presence => true
  id_property :id, on: :id_builder, constraint: false

  def id_builder
    # only need to fill this out if you're gonna write to the db
  end
end

Defined Under Namespace

Modules: Accessor, ClassMethods, TypeMethods

Instance Attribute Summary

Attributes included from Accessor

#default_property_value

Method Summary

Methods included from Accessor

#default_properties, #default_properties=, #default_property, #default_property_key