riak-shim 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,6 +4,8 @@ A teeny shim between your code and the riak-client gem. Reads database configur
4
4
  out of config/database.yml and derives bucket names from your class names and an
5
5
  appropriate prefix.
6
6
 
7
+ Riak is a database from the good people at Basho. Check it out: http://basho.com/products/riak-overview/
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -20,7 +22,38 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
25
+ Create a config/database.yml containing the details of your Riak like so:
26
+
27
+ development: &default
28
+ bucket_prefix: dev_
29
+ host: localhost
30
+ http_port: 8098
31
+
32
+ test:
33
+ <<: *default
34
+ bucket_prefix: test_
35
+
36
+ In any class you wish to persist:
37
+ include Riak::Shim::Persistable
38
+
39
+ def to_hash
40
+ # Return hashified version of your class
41
+ end
42
+
43
+ def fields_to_index
44
+ # Return an Array of hash keys you would like placed into a secondary index.
45
+ # Return an empty Array if you don't know what this means. :)
46
+ end
23
47
 
48
+ Now you can save instances of that class by calling #save on them and retrieve them from Riak by calling
49
+
50
+ YourClass.for_index(index_name, value)
51
+
52
+ Where `index_name` is what you defined in `fields_to_index` plus the suffix "_bin" .
53
+
54
+ The `value` is what you want to look up.
55
+
56
+ Return value is an Array of instances of your class matching the query.
24
57
 
25
58
  ## Contributing
26
59
 
@@ -29,3 +62,7 @@ Or install it yourself as:
29
62
  3. Commit your changes (`git commit -am 'Added some feature'`)
30
63
  4. Push to the branch (`git push origin my-new-feature`)
31
64
  5. Create new Pull Request
65
+
66
+ ## TODOS
67
+
68
+ - Implement a #for_key lookup method.
@@ -3,6 +3,11 @@ module Riak
3
3
 
4
4
  module Persistable
5
5
  attr_writer :store
6
+ attr_accessor :key
7
+
8
+ def key
9
+ @key ||= gen_key
10
+ end
6
11
 
7
12
  def bucket
8
13
  return self.class.store.bucket(bucket_name)
@@ -1,5 +1,5 @@
1
1
  module Riak
2
2
  module Shim
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-shim
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Brodhead & Shai Rosenfeld