riak-record 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85acfab0540c576334b9040c88a76e04c5a9d59f
4
- data.tar.gz: db8d4bb1ad14f2b93866512641a7d13d13068f44
3
+ metadata.gz: cb4640475e65d8b57d7dd89fb6bcea9dc8b98efc
4
+ data.tar.gz: 07bc6462e699e51c3997c722bbaa03fa22f4ef6a
5
5
  SHA512:
6
- metadata.gz: 6abaf2c13290039a9d166fa0ac863259b9bb7a4b4235be3a59a339c25f478e956b61e7acf4117288d6748770231fb27e621e691a04161097d945c8118bb7b4e7
7
- data.tar.gz: b3420c21d49b66f30ce5ff1a1d7fdc0c5e5232dcc35ebd3a933b1bbec2b01f0a07374d4dfe41e7677796506bbd448846fa89a020fe0577225dd876b3d253f91c
6
+ metadata.gz: ed8334fa967f783728aacd07603cf3454d26e16398ffa30babc0a806933d216ef85feb0f06a3e86db297fcfff881ef2895fc4c35f4f990222254362fffe38ad6
7
+ data.tar.gz: 22cb2b18af1bd6245986cbc371e03829b20a939699f78846407a238a18d5786d2a541e204e94e0d3f96132031bde38fecdd136dec3f6c818c80c5e70fa08c04e
data/README.md CHANGED
@@ -9,6 +9,7 @@ each class, provides a simple finder, and creates attribute reader.
9
9
  require 'riak-record'
10
10
 
11
11
  RiakRecord.client = Riak::Client.new
12
+ RiakRecord.namespace = 'staging' # optional. Namespaces buckets
12
13
 
13
14
  class ExampleRecord < RiakRecord
14
15
  bucket_name 'example_a'
@@ -22,6 +23,8 @@ record = ExampleRecord.find("a-key")
22
23
  record.riak_object #> directly access Riak::RObject
23
24
  record.data #> same as record.riak_object.data
24
25
  record.attribute1 #> record.riak_object.data[:attribute1]
26
+ record.attribute1 = 'name'
27
+ record.save #> record.riak_object.store
25
28
  ```
26
29
 
27
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/lib/riak-record.rb CHANGED
@@ -14,16 +14,16 @@ class RiakRecord
14
14
  end
15
15
 
16
16
  def save
17
- riak_object.store
17
+ riak_object.store(:returnbody => false)
18
18
  end
19
19
 
20
20
  def self.bucket_name(name = :not_a_name)
21
21
  @bucket_name = name unless name == :not_a_name
22
- @bucket_name
22
+ namespace.present? ? namespace+":-:"+@bucket_name : @bucket_name
23
23
  end
24
24
 
25
25
  def self.bucket
26
- @bucket ||= client.bucket(@bucket_name)
26
+ @bucket ||= client.bucket(bucket_name)
27
27
  end
28
28
 
29
29
  def self.record_attributes(*attributes)
@@ -57,6 +57,15 @@ class RiakRecord
57
57
  keys.map{ |k| hash[k] }
58
58
  end
59
59
 
60
+ @@namespace = nil
61
+ def self.namespace=(namespace)
62
+ @@namespace = namespace
63
+ end
64
+
65
+ def self.namespace
66
+ @@namespace
67
+ end
68
+
60
69
  def self.client=(client)
61
70
  @@client = client
62
71
  end
data/riak-record.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: riak-record 0.0.3 ruby lib
5
+ # stub: riak-record 0.0.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "riak-record"
9
- s.version = "0.0.3"
9
+ s.version = "0.0.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -92,4 +92,11 @@ describe "RiakRecord" do
92
92
  end
93
93
 
94
94
  end
95
+
96
+ describe "namespacing buckets" do
97
+ it "should prepend namespace to bucket name" do
98
+ RiakRecord.namespace = "namespace_test"
99
+ expect(ExampleA.bucket_name).to eq("namespace_test:-:example_a")
100
+ end
101
+ end
95
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Graff