Module: CassandraObject::Scope::QueryMethods

Included in:
CassandraObject::Scope
Defined in:
lib/cassandra_object/scope/query_methods.rb

Instance Method Summary collapse

Instance Method Details

#limit(value) ⇒ Object



31
32
33
# File 'lib/cassandra_object/scope/query_methods.rb', line 31

def limit(value)
  clone.limit! value
end

#limit!(value) ⇒ Object



26
27
28
29
# File 'lib/cassandra_object/scope/query_methods.rb', line 26

def limit!(value)
  self.limit_value = value
  self
end

#select(*values, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/cassandra_object/scope/query_methods.rb', line 9

def select(*values, &block)
  if block_given?
    to_a.select(&block)
  else
    clone.select! *values
  end
end

#select!(*values) ⇒ Object



4
5
6
7
# File 'lib/cassandra_object/scope/query_methods.rb', line 4

def select!(*values)
  self.select_values += values.flatten
  self
end

#to_aObject



44
45
46
# File 'lib/cassandra_object/scope/query_methods.rb', line 44

def to_a
  instantiate_from_cql(to_cql)
end

#to_cqlObject



35
36
37
38
39
40
41
42
# File 'lib/cassandra_object/scope/query_methods.rb', line 35

def to_cql
  [
      "SELECT #{select_string} FROM #{klass.column_family}",
      consistency_string,
      where_string,
      limit_string
  ].delete_if(&:blank?) * ' '
end

#where(*values) ⇒ Object



22
23
24
# File 'lib/cassandra_object/scope/query_methods.rb', line 22

def where(*values)
  clone.where! values
end

#where!(*values) ⇒ Object



17
18
19
20
# File 'lib/cassandra_object/scope/query_methods.rb', line 17

def where!(*values)
  self.where_values += values.flatten
  self
end