Class: OrientDB::AR::Update

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Update.



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

def initialize(model, command = OrientDB::SQL::Update.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/update.rb', line 3

def command
  @command
end

#modelObject

Returns the value of attribute model.



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

def model
  @model
end

Class Method Details

.from_query(query, *args) ⇒ Object



21
22
23
24
25
26
# File 'lib/orientdb-ar/sql/update.rb', line 21

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

Instance Method Details

#inspectObject Also known as: to_s



28
29
30
# File 'lib/orientdb-ar/sql/update.rb', line 28

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

#runObject



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

def run
  model.connection.run_command command.to_s
end