Class: Virsandra::Query
- Inherits:
-
Object
show all
- Defined in:
- lib/virsandra/query.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#row ⇒ Object
Returns the value of attribute row.
6
7
8
|
# File 'lib/virsandra/query.rb', line 6
def row
@row
end
|
#statement ⇒ Object
Returns the value of attribute statement.
7
8
9
|
# File 'lib/virsandra/query.rb', line 7
def statement
@statement
end
|
#table=(value) ⇒ Object
7
8
9
|
# File 'lib/virsandra/query.rb', line 7
def table=(value)
@table = value
end
|
Class Method Details
.alter ⇒ Object
23
24
25
|
# File 'lib/virsandra/query.rb', line 23
def alter
AlterQuery.new
end
|
.delete ⇒ Object
19
20
21
|
# File 'lib/virsandra/query.rb', line 19
def delete
DeleteQuery.new
end
|
.insert ⇒ Object
15
16
17
|
# File 'lib/virsandra/query.rb', line 15
def insert
InsertQuery.new
end
|
.select(*fields) ⇒ Object
11
12
13
|
# File 'lib/virsandra/query.rb', line 11
def select(*fields)
SelectQuery.new(fields)
end
|
Instance Method Details
#add(*args) ⇒ Object
50
51
52
|
# File 'lib/virsandra/query.rb', line 50
def add *args
raise InvalidQuery.new("Add clause not defined for #{self.class}")
end
|
#execute ⇒ Object
58
59
60
61
|
# File 'lib/virsandra/query.rb', line 58
def execute
@row = Virsandra.execute(self.to_s)
end
|
#fetch(statement = nil) ⇒ Object
63
64
65
66
67
|
# File 'lib/virsandra/query.rb', line 63
def fetch(statement = nil)
@raw_query = statement if statement
execute
fetch_with_symbolized_keys
end
|
#from(*args) ⇒ Object
Also known as:
table, into
32
33
34
|
# File 'lib/virsandra/query.rb', line 32
def from *args
raise InvalidQuery.new("From, table or into clause not defined for #{self.class}")
end
|
#limit(*args) ⇒ Object
46
47
48
|
# File 'lib/virsandra/query.rb', line 46
def limit *args
raise InvalidQuery.new("Limit clause not defined for #{self.class}")
end
|
#order(*args) ⇒ Object
42
43
44
|
# File 'lib/virsandra/query.rb', line 42
def order *args
raise InvalidQuery.new("Order clause not defined for #{self.class}")
end
|
#to_s ⇒ Object
28
29
30
|
# File 'lib/virsandra/query.rb', line 28
def to_s
raw_query.map{|query_part| query_part.to_s }.reject(&:empty?).join(" ")
end
|
#values(*args) ⇒ Object
54
55
56
|
# File 'lib/virsandra/query.rb', line 54
def values *args
raise InvalidQuery.new("Values clause not defined for #{self.class}")
end
|
#where(*args) ⇒ Object
38
39
40
|
# File 'lib/virsandra/query.rb', line 38
def where *args
raise InvalidQuery.new("Where clause not defined for #{self.class}")
end
|