ryanking / cassandra_object forked from NZKoz/cassandra_object

A library for persisting your objects into cassandra.

This URL has Read+Write access

commit  52f83bc2b69ce893a08d40c60bb6db8f1bfcafaf
tree    5866abb6743094b833d60a46298503195eb2139a
parent  f12421aefc6509dcc1171da766435cff82d9ee67
name age message
file .gitignore Thu Aug 27 11:01:35 -0700 2009 ignore yard stuff [jamesgolick]
file LICENSE Wed Jul 15 02:50:29 -0700 2009 First commit, WAY ugly [NZKoz]
file README Wed Aug 26 09:04:15 -0700 2009 change steps to getting things working, since r... [jamesgolick]
file Rakefile Thu Aug 27 11:07:41 -0700 2009 add YARDOC rake task [jamesgolick]
file SPEC Sun Jul 26 18:41:12 -0700 2009 status update [NZKoz]
file VERSION Wed Aug 26 09:11:23 -0700 2009 Version bump to 0.0.0 [jamesgolick]
directory lib/ Loading commit data...
directory test/
directory vendor/ Thu Sep 03 17:42:01 -0700 2009 move the requiring of I18n out of active_model [ryanking]
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.