Class: OrientDB::AR::Delete

Inherits:
Object
  • Object
show all
Defined in:
lib/orientdb-ar/sql/delete.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, command = OrientDB::SQL::Delete.new) ⇒ Delete

Returns a new instance of Delete.



5
6
7
8
# File 'lib/orientdb-ar/sql/delete.rb', line 5

def initialize(model, command = OrientDB::SQL::Delete.new)
  @model, @command = model, command
  @command.oclass model.oclass_name
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



3
4
5
# File 'lib/orientdb-ar/sql/delete.rb', line 3

def command
  @command
end

#modelObject

Returns the value of attribute model.



3
4
5
# File 'lib/orientdb-ar/sql/delete.rb', line 3

def model
  @model
end

Class Method Details

.from_query(query) ⇒ Object



17
18
19
20
21
# File 'lib/orientdb-ar/sql/delete.rb', line 17

def self.from_query(query)
  obj = new query.model
  obj.command.instance_variable_set "@conditions", query.query.instance_variable_get("@conditions")
  obj
end

Instance Method Details

#inspectObject Also known as: to_s



27
28
29
# File 'lib/orientdb-ar/sql/delete.rb', line 27

def inspect
  %{#<OrientDB::AR::Delete:#{model.name} command="#{command.to_s}">}
end

#runObject



23
24
25
# File 'lib/orientdb-ar/sql/delete.rb', line 23

def run
  model.connection.run_command command.to_s
end