NZKoz / cassandra_object
- Source
- Commits
- Network (7)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
dc9dcba
commit dc9dcbaf78d916c1a7132b87c5031632bfaaf3e6
tree 26aaf089774133ce12cdc3f9cf9ee12b2ab0da1b
parent 35df082427808ae631dd4063a79a65c0cda803af parent cbe42c778c5f211189f5866abb6f0e8b8144a28c
tree 26aaf089774133ce12cdc3f9cf9ee12b2ab0da1b
parent 35df082427808ae631dd4063a79a65c0cda803af parent cbe42c778c5f211189f5866abb6f0e8b8144a28c
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Aug 27 11:01:35 -0700 2009 | |
| |
LICENSE | Wed Jul 15 02:50:29 -0700 2009 | |
| |
README | Wed Aug 26 09:04:15 -0700 2009 | |
| |
Rakefile | Sat Oct 17 17:08:02 -0700 2009 | |
| |
SPEC | Sun Jul 26 18:41:12 -0700 2009 | |
| |
VERSION | Sat Oct 17 17:08:02 -0700 2009 | |
| |
lib/ | Wed Nov 04 16:42:58 -0800 2009 | |
| |
test/ | Wed Nov 04 16:45:25 -0800 2009 | |
| |
vendor/ | Thu Sep 03 17:42:01 -0700 2009 |
README
Provides a nice API for cassandra backed storage. Because I'm too lazy to write docs for something so new, here is an
example:
class Customer < CassandraObject::Base
attribute :first_name, :type => String
attribute :last_name, :type => String
attribute :date_of_birth, :type => Date
validate :should_be_cool
key :uuid
index :last_name
association :invoices, :unique=>false, :inverse_of=>:customer
private
def should_be_cool
unless ["Michael", "Anika", "Evan", "James"].include?(first_name)
errors.add(:first_name, "must be that of a cool person")
end
end
end
class Invoice < CassandraObject::Base
attribute :number, :type=>Integer
attribute :total, :type=>Float
attribute :gst_number, :type=>String
index :number, :unique=>true
association :customer, :unique=>true, :inverse_of=>:invoices
migrate 1 do |attrs|
attrs["total"] ||= rand(2000) / 100.0
end
migrate 2 do |attrs|
attrs["gst_number"] = "66-666-666"
end
key do
ActiveSupport::SecureRandom.hex(64)
end
end
FAQ
===
# How do I make this work?
Here are some basic directions:
1. Clone Evan Weaver's cassandra gem repository: `git clone git://github.com/fauna/cassandra.git`
2. `sudo gem install echoe`
3. `rake cassandra`
4. `git clone git://github.com/NZKoz/cassandra_object.git`
5. You can now drop into irb, and require 'cassandra_object/lib/cassandra_object'
6. CassandraObject::Base.establish_connection "Twitter"
7. Create a class that inherits from CassandraObject::Base
8.1. Note that you'll need to modify storage-conf.xml in the cassandra repository you cloned in step #1 if you want
to change the column families or anything.
Sorry, it's hard right now. If you can't figure it out you should ask nzkoz for help on #cassandra on freenode.
You need to have a checkout of edge rails in ../rails if you want to run the tests.
# Should I use this in production?
Only if you're looking to help out with the development, there are a bunch of rough edges right now.
