Class: Believer::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/believer/command.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attrs = {}) ⇒ Command
Returns a new instance of Command.
6
7
8
9
10
11
|
# File 'lib/believer/command.rb', line 6
def initialize(attrs = {})
attrs.each do |name, value|
send("#{name}=", value)
end if attrs.present?
end
|
Instance Attribute Details
#record_class ⇒ Object
Returns the value of attribute record_class.
4
5
6
|
# File 'lib/believer/command.rb', line 4
def record_class
@record_class
end
|
Instance Method Details
#clone ⇒ Object
13
14
15
|
# File 'lib/believer/command.rb', line 13
def clone
self.class.new(query_attributes)
end
|
#connection ⇒ Object
21
22
23
|
# File 'lib/believer/command.rb', line 21
def connection
@record_class.connection
end
|
#execute(name = 'cql.cql_record') ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/believer/command.rb', line 25
def execute(name = 'cql.cql_record')
cql = to_cql
begin
start = Time.now
puts "Executing #{cql}"
res = connection.execute(cql)
return res
rescue Cql::Protocol::DecodingError => e
@record_class.reset_connection
raise e
end
end
|
#query_attributes ⇒ Object
17
18
19
|
# File 'lib/believer/command.rb', line 17
def query_attributes
{:record_class => @record_class}
end
|