module Neoon::Model::Node

Public Instance Methods

neo_create() click to toggle source
# File lib/neoon/model/node.rb, line 14
def neo_create
  _cypher_query.create_node.result.data
end
Also aliased as: neo_save, neo_update
neo_destroy() click to toggle source
# File lib/neoon/model/node.rb, line 20
def neo_destroy
  _cypher_query.delete_node.result.data
end
neo_node() click to toggle source
# File lib/neoon/model/node.rb, line 5
def neo_node
  _node = _cypher_query.find_node.result.data
  if _node.empty?
    excep = { :message => "Cannot find node with id [#{_cypher_query.id}] in database.", :exception => "NodeNotFoundException" }
    raise Neoon::Error::NodeNotFoundException.new excep, excep
  end
  _node.first.first.data
end
neo_node_properties() click to toggle source
# File lib/neoon/model/node.rb, line 24
def neo_node_properties
  _neo_node.merge(:_id => self.id)
end
neo_save()
Alias for: neo_create
neo_update()
Alias for: neo_create

Protected Instance Methods

_cypher_query() click to toggle source
# File lib/neoon/model/node.rb, line 30
def _cypher_query
  Neoon::Cypher::InstanceQuery.new(self)
end
_neo_node() click to toggle source
# File lib/neoon/model/node.rb, line 34
def _neo_node
  return {} unless self.class.neo_model_config.properties
  hash = self.class.neo_model_config.properties.inject({}) do |all, (field, block)|
    all[field] = if block[:block]
      instance_eval(&block[:block])
    else
      self.send(field) rescue (raise "No field #{field} for #{self.class.name}")
    end
    all
  end
  hash.reject { |k, v| v.nil? }
end