Module: ActiveNode::Persistence

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_node/persistence.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



49
50
51
# File 'lib/active_node/persistence.rb', line 49

def node
  @node
end

Instance Method Details

#destroy(include_relationships = false) ⇒ Object



77
78
79
80
81
# File 'lib/active_node/persistence.rb', line 77

def destroy include_relationships=false
  destroyable = destroy_associations include_relationships
  node.del if destroyable
  @destroyed = destroyable
end

#destroy!Object



83
84
85
# File 'lib/active_node/persistence.rb', line 83

def destroy!
  destroy true
end

#idObject Also known as: to_param, persisted?



54
55
56
# File 'lib/active_node/persistence.rb', line 54

def id
  neo_id && neo_id.to_i
end

#incoming(types = nil, klass = nil) ⇒ Object



87
88
89
# File 'lib/active_node/persistence.rb', line 87

def incoming(types=nil, klass=nil)
  related(:incoming, types, klass)
end

#initialize(object = {}) ⇒ Object



61
62
63
64
65
# File 'lib/active_node/persistence.rb', line 61

def initialize object={}
  hash=object
  @node, hash = object, object.send(:table) if object.is_a? Neography::Node
  super hash
end

#new_record?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/active_node/persistence.rb', line 67

def new_record?
  !id
end

#outgoing(types = nil, klass = nil) ⇒ Object



91
92
93
# File 'lib/active_node/persistence.rb', line 91

def outgoing(types=nil, klass=nil)
  related(:outgoing, types, klass)
end

#saveObject Also known as: save!



71
72
73
# File 'lib/active_node/persistence.rb', line 71

def save(*)
  create_or_update
end