Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A lightweight Ruby ORM for Riak

Merge pull request #17 from chrisroberts/enhancement/values-access

Use accessor method when accessing the values hash
latest commit 2f3dac30ff
Kyle Kingsbury authored
Failed to load latest commit information.
lib Use accessor method when accessing the values hash
spec
.gitignore Add .ruby-version and .ruby-gemset to .gitignore
.rspec Proper RSpec structure for specs
Gemfile
Gemfile.lock Upgrade to riak-client 1.4.0
LICENSE Add MIT license
README.markdown Add contributer
Rakefile.rb Add rake task for deleting risky test buckets
risky.gemspec Upgrade to riak-client 1.4.0

README.markdown

Risky

A simple, lightweight object layer for Riak.

$ gem install risky

class User < Risky
  bucket :users
end

User.new('clu', 'fights' => 'for the users').save
User['clu']['fights'] #=> 'for the users'

Built on top of basho's excellent riak-client, Risky provides basic infrastructure for designing models with attributes (including defaults and casting to/from JSON), conflict resolution, validation, lifecycle callbacks, link-walking, mapreduce, and more. Modules are available for timestamps, chronologically ordered lists, and secondary indexes (2i).

Risky does not provide the rich API of Ripple, but it also does not require activesupport. It strives to be understandable, minimal, and modular. Magic is avoided in favor of module composition and a compact API.

Risky stores every instance of a model in a given bucket, indexed by key. Objects are stored as JSON hashes.

Show me the code!

class User < Risky
  include Risky::Indexes
  include Risky::Timestamps

  bucket :users

  # Provides user.name instead of user['name']
  value :name
  value :twitter, :default => {}

  # :class is used to cast times from JSON back into Time objects.
  value :updated_at, :class => Time
  value :created_at, :class => Time

  # Provides User.by_name. Changing the name stores an object in the
  # users_by_name bucket, with key user.name, linking back to us. A
  # validate function is used to ensure uniqueness before saving.
  index :name, :unique => true

  # Here, a custom proc returns the key used for the index.
  index :twitter_id, :proc => lambda { |user| user.twitter['id'] }

  # Provides user.followers, a list of links with the 'followers' tag.
  links :followers
end

Contributors

Dalibor Nasevic (@dalibor) Marc Heiligers (@marcheiligers)

License

Risky was developed by Kyle Kingsbury aphyr@aphyr.com at http://vodpod.com, for their iPad social video app "Showyou". Generous thanks to Sean Cribbs, Mark Phillips, the Basho team, and all the other #riak'ers. Released under the MIT license.

Something went wrong with that request. Please try again.