Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Making find_all work

  • Loading branch information...
commit 838c7c5a6dd97874e88da7332498630461a981e5 1 parent 85cbacc
German Otero authored
View
4 lib/cassandra_object/cursor.rb
@@ -1,10 +1,10 @@
module CassandraObject
class Cursor
- def initialize(target_class, column_family, key, super_column, options={})
+ def initialize(target_class, column_family, key, super_column = nil, options={})
@target_class = target_class
@column_family = column_family
@key = key.to_s
- @super_column = super_column
+ @super_column = super_column if super_column
@options = options
@validators = []
end
View
8 lib/cassandra_object/indexes.rb
@@ -45,11 +45,13 @@ class Index
def initialize(attribute_name, model_class, options)
@attribute_name = attribute_name
@model_class = model_class
- @reversed = options[:reversed]
+ @reversed = false
+ @reversed = options[:reversed] if options[:reversed]
+
end
def find(attribute_value, options = {})
- cursor = CassandraObject::Cursor.new(@model_class, column_family, attribute_value.to_s, @attribute_name.to_s, :start_after=>options[:start_after], :reversed=>@reversed)
+ cursor = CassandraObject::Cursor.new(@model_class, column_family, attribute_value.to_s, @attribute_name, :start_after=>options[:start_after], :reversed=>@reversed)
cursor.validator do |object|
object.send(@attribute_name) == attribute_value
end
@@ -57,7 +59,7 @@ def find(attribute_value, options = {})
end
def write(record)
- @model_class.connection.insert(column_family, record.send(@attribute_name).to_s, {@attribute_name.to_s=>record.key.to_s})
+ @model_class.connection.insert(column_family, record.send(@attribute_name).to_s, {@attribute_name.to_s=>{record.key.to_s => new_key}})
end
def remove(record)
View
3  lib/cassandra_object/persistence.rb
@@ -62,8 +62,7 @@ def remove(key)
def all(keyrange = ''..'', options = {})
results = connection.get_range(column_family, :start => keyrange.first, :finish => keyrange.last, :count=>(options[:limit] || 100))
- #keys = results.map(&:key)
- #keys.map {|key| get(key) }
+ results.keys.map {|key| get(key) }
end
def first(keyrange = ''..'', options = {})
Please sign in to comment.
Something went wrong with that request. Please try again.