Module: Arango::Graph::InstanceMethods

Defined in:
lib/arango/graph/instance_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



27
28
29
# File 'lib/arango/graph/instance_methods.rb', line 27

def database
  @database
end

Instance Method Details

#createArango::DocumentCollection

Stores the graph in the database.

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/arango/graph/instance_methods.rb', line 61

def create
  @name_changed = false
  @wait_for_sync_changed = false

  body = {}.merge(@attributes)
  body.merge!(@changed_attributes)

  @properties.each do |k, v|
    body[:options][k.to_s.camelize(:lower)] = v unless v.nil?
  end

  params = {}
  if @wait_for_sync_changed
    params[:waitForSync] = @wait_for_sync
  end
  result = Arango::Requests::Graph::Create.execute(server: @database.server, body: body, params: params)
  _update_attributes(result.graph)
  self
end

#deleteNilClass

Deletes a graph.

Returns:

  • (NilClass)


83
84
85
86
# File 'lib/arango/graph/instance_methods.rb', line 83

def delete
  args = { graph: @name }
  Arango::Requests::Graph::Delete.execute(server: @database.server, args: args)
end

#idObject



29
30
31
# File 'lib/arango/graph/instance_methods.rb', line 29

def id
  @changed_attributes[:_id] || @attributes[:_id]
end

#id=(i) ⇒ Object



33
34
35
# File 'lib/arango/graph/instance_methods.rb', line 33

def id=(i)
  @changed_attributes[:_id] = i
end

#initialize(database: Arango.current_database, name:, edge_definitions: [], is_smart: false, properties: {}) ⇒ Arango::Graph

Instantiate a new collection. For param description see the attributes descriptions. All params except name and database are optional.

Parameters:

  • name (String)

    The name of the collection.

  • database (Arango::Database) (defaults to: Arango.current_database)
  • status

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/arango/graph/instance_methods.rb', line 11

def initialize(database: Arango.current_database,
               name:, edge_definitions: [], is_smart: false,
               properties: {})
  @attributes = { name: name, edge_definitions: edge_definitions }
  @changed_attributes = {}
  send(:database=, database)
  @aql = nil
  @batch_proc = nil
  _set_name(name)
  @name_changed = false
  @original_name = name
  @edge_definitions = edge_definitions
  @orphan_collections = []
  _set_properties(properties)
end

#nameObject



37
38
39
# File 'lib/arango/graph/instance_methods.rb', line 37

def name
  @changed_attributes[:name] || @attributes[:name]
end

#name=(n) ⇒ Object



41
42
43
44
# File 'lib/arango/graph/instance_methods.rb', line 41

def name=(n)
  @name_changed = true
  _set_name(n)
end

#revisionObject



46
47
48
# File 'lib/arango/graph/instance_methods.rb', line 46

def revision
  @properties[:_rev]
end

#to_hObject



50
51
52
# File 'lib/arango/graph/instance_methods.rb', line 50

def to_h
  @attributes.delete_if{|_,v| v.nil?}
end

#wait_for_sync=(n) ⇒ Object



54
55
56
57
# File 'lib/arango/graph/instance_methods.rb', line 54

def wait_for_sync=(n)
  @wait_for_sync_changed = true
  @properties[:wait_for_sync] = n
end