Module: Arango::Graph::InstanceMethods
- Defined in:
- lib/arango/graph/instance_methods.rb
Overview
Arango Graph InstanceMethods
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
Instance Method Summary collapse
-
#create ⇒ Arango::DocumentCollection
Stores the graph in the database.
-
#delete ⇒ NilClass
Deletes a graph.
- #id ⇒ Object
- #id=(i) ⇒ Object
-
#initialize(database: Arango.current_database, name:, edge_definitions: [], is_smart: false, properties: {}) ⇒ Arango::Graph
Instantiate a new collection.
- #name ⇒ Object
- #name=(n) ⇒ Object
- #revision ⇒ Object
- #to_h ⇒ Object
- #wait_for_sync=(n) ⇒ Object
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
31 32 33 |
# File 'lib/arango/graph/instance_methods.rb', line 31 def database @database end |
Instance Method Details
#create ⇒ Arango::DocumentCollection
Stores the graph in the database.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/arango/graph/instance_methods.rb', line 65 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 |
#delete ⇒ NilClass
Deletes a graph.
87 88 89 90 |
# File 'lib/arango/graph/instance_methods.rb', line 87 def delete args = { graph: @name } Arango::Requests::Graph::Delete.execute(server: @database.server, args: args) end |
#id ⇒ Object
33 34 35 |
# File 'lib/arango/graph/instance_methods.rb', line 33 def id @changed_attributes[:_id] || @attributes[:_id] end |
#id=(i) ⇒ Object
37 38 39 |
# File 'lib/arango/graph/instance_methods.rb', line 37 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 are optional.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/arango/graph/instance_methods.rb', line 15 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 |
#name ⇒ Object
41 42 43 |
# File 'lib/arango/graph/instance_methods.rb', line 41 def name @changed_attributes[:name] || @attributes[:name] end |
#name=(n) ⇒ Object
45 46 47 48 |
# File 'lib/arango/graph/instance_methods.rb', line 45 def name=(n) @name_changed = true _set_name(n) end |
#revision ⇒ Object
50 51 52 |
# File 'lib/arango/graph/instance_methods.rb', line 50 def revision @properties[:_rev] end |
#to_h ⇒ Object
54 55 56 |
# File 'lib/arango/graph/instance_methods.rb', line 54 def to_h @attributes.delete_if{|_,v| v.nil?} end |
#wait_for_sync=(n) ⇒ Object
58 59 60 61 |
# File 'lib/arango/graph/instance_methods.rb', line 58 def wait_for_sync=(n) @wait_for_sync_changed = true @properties[:wait_for_sync] = n end |