Module: Keymaker::Node::ClassMethods

Extended by:
Forwardable
Defined in:
lib/keymaker/node.rb

Instance Method Summary collapse

Instance Method Details

#create(attributes) ⇒ Object



55
56
57
# File 'lib/keymaker/node.rb', line 55

def create(attributes)
  new(attributes).save
end

#find(node_id) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/keymaker/node.rb', line 67

def find(node_id)
  node = neo_service.get_node(node_id)
  if node.present?
    new(node.slice(*properties)).tap do |neo_node|
      neo_node.node_id = node.neo4j_id
      neo_node.new_node = false
    end
  end
end

#find_all_by_cypher(query, params = {}) ⇒ Object



63
64
65
# File 'lib/keymaker/node.rb', line 63

def find_all_by_cypher(query, params={})
  neo_service.execute_cypher(query, params)
end

#find_by_cypher(query, params = {}) ⇒ Object



59
60
61
# File 'lib/keymaker/node.rb', line 59

def find_by_cypher(query, params={})
  find_all_by_cypher(query, params).first
end

#propertiesObject



46
47
48
# File 'lib/keymaker/node.rb', line 46

def properties
  property_traits.keys
end

#property(attribute, type = String) ⇒ Object



50
51
52
53
# File 'lib/keymaker/node.rb', line 50

def property(attribute,type=String)
  property_traits[attribute] = type
  attr_accessor attribute
end