riakrest 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ ## OS X
2
+ .DS_Store
3
+
4
+ ## emacs
5
+ TAGS
6
+ *~
7
+ .#*
8
+
9
+ ## gem
10
+ pkg/*
11
+ rdoc/*
12
+ *.gemspec
13
+
14
+ ##
15
+ doc/*
16
+ log/*
17
+ tmp/*
18
+
data/History.txt CHANGED
@@ -1,4 +1,7 @@
1
+ === 0.0.2 2009-10-30
2
+
3
+ * Clean-up:
4
+
1
5
  === 0.0.1 2009-10-20
2
6
 
3
7
  * Initial release:
4
- * Still pre-alpha
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 Paul Rogers, DingoSky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,51 +1,77 @@
1
- = riakrest
1
+ = RiakRest
2
2
 
3
3
  http://github.com/wcpr/riakrest
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
7
  RiakRest provides structured, RESTful interaction with a Riak document
8
- store. In Riak parlance, this JSON data exchange is called Jiak. RiakRest
9
- provides two levels of interaction: Core Client and Resource. Core Client
10
- interaction works down at the Jiak level and exposes Jiak internals. Resource
11
- interaction is an abstraction built on top of the Core Client.
8
+ store.
12
9
 
13
- == FEATURES/PROBLEMS:
10
+ == RIAK:
14
11
 
12
+ Riak[http://riak.basho.com] is an open-source project developed and maintained
13
+ by the fine folks at Basho[http://www.basho.com]. It combines a decentralized
14
+ key-value store, a flexible map/reduce engine, and a friendly HTTP/JSON query
15
+ interface to provide a database ideally suited for Web applications. RiakRest
16
+ interacts with the HTTP/JSON query interface, which is called Jiak.
15
17
 
16
18
  == SYNOPSIS:
17
19
 
20
+ RiakRest provides structured, RESTful interaction with the HTTP/JSON interface
21
+ of a Riak[http://riak.basho.com] document data store. RiakRest provides two
22
+ levels of interaction: Core Client and Resource. Core Client works at the Jiak
23
+ level and exposes Jiak internals. JiakResource is an abstraction built on top
24
+ of the Core Client that gives a true RESTful feel.
18
25
 
19
26
  == REQUIREMENTS:
20
27
 
21
- RestClient is used for REST server interaction.
28
+ RestClient is used for REST server interaction
29
+
22
30
  JSON is used for data exchange.
23
31
 
32
+ Riak[http://riak.basho.com] provides the HTTP/JSON Jiak interface and data
33
+ store.
34
+
24
35
  == INSTALL:
25
36
 
26
37
  sudo gem install riakrest
27
38
 
28
- == LICENSE:
39
+ == EXAMPLE
40
+ require 'riakrest'
41
+ include RiakRest
42
+
43
+ PersonData = JiakDataHash.create(:name,:age)
44
+ PersonData.keygen :name
45
+
46
+ class Person
47
+ include JiakResource
48
+ server 'http://localhost:8002/jiak'
49
+ group 'people'
50
+ data_class PersonData
51
+ auto_post true
52
+ auto_update true
53
+ end
29
54
 
30
- (The MIT License)
55
+ remy = Person.new(:name => 'remy',:age => 10) # (auto-post)
56
+ puts remy.name # => "remy" (auto-update)
31
57
 
32
- Copyright (c) 2009 Paul Rogers, DingoSky LLC
58
+ puts Person.get('remy').name # => "remy" (from Jiak server)
59
+ puts Person.get('remy').age # => 10 (from Jiak server)
33
60
 
34
- Permission is hereby granted, free of charge, to any person obtaining
35
- a copy of this software and associated documentation files (the
36
- 'Software'), to deal in the Software without restriction, including
37
- without limitation the rights to use, copy, modify, merge, publish,
38
- distribute, sublicense, and/or sell copies of the Software, and to
39
- permit persons to whom the Software is furnished to do so, subject to
40
- the following conditions:
61
+ remy.age = 11 # (auto-update)
62
+ puts Person.get('remy').age # => 11 (from Jiak server)
63
+
64
+ callie = Person.new(:name => 'Callie', :age => 13)
65
+ remy.link(callie,'sister')
66
+
67
+ sisters = remy.query(Person,'sister')
68
+ puts sisters[0].eql?(callie) # => true
69
+
70
+ remy.delete
71
+ callie.delete
72
+
73
+ == LICENSE:
41
74
 
42
- The above copyright notice and this permission notice shall be
43
- included in all copies or substantial portions of the Software.
75
+ Copyright (c) 2009 Paul Rogers, DingoSky. See LICENCE for details.
44
76
 
45
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
46
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
48
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
49
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
50
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
+ ===Go forth and Riak!
data/Rakefile CHANGED
@@ -1,24 +1,55 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/riakrest'
6
-
7
- Hoe.plugin :newgem
8
-
9
- # Generate all the Rake tasks
10
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
11
- $hoe = Hoe.spec 'riakrest' do
12
- self.developer 'Paul Rogers', 'paul@dingosky.com'
13
- self.post_install_message = 'PostInstall.txt'
14
- self.rubyforge_name = self.name # TODO this is default value
15
- # self.extra_deps = [['activesupport','>= 2.0.2']]
16
-
17
- end
18
-
19
- require 'newgem/tasks'
20
- Dir['tasks/**/*.rake'].each { |t| load t }
21
-
22
- # TODO - want other tests/tasks run by default? Add them to the list
23
- # remove_task :default
24
- # task :default => [:spec, :features]
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ rescue LoadError
7
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
8
+ end
9
+
10
+ Jeweler::Tasks.new do |gem|
11
+ gem.name = "riakrest"
12
+ gem.summary = %Q{RiakRest provides structured, RESTful interaction with a Riak document store.}
13
+ gem.description = <<-EOH
14
+ RiakRest provides structured, RESTful interaction with
15
+ the HTTP/JSON interface of a Riak[http://riak.basho.com] document data
16
+ store. RiakRest provides two levels of interaction: Core Client and
17
+ Resource. Core Client works at the Jiak level and exposes Jiak
18
+ internals. JiakResource is an abstraction built on top of the Core Client
19
+ that gives a true RESTful feel.
20
+ EOH
21
+ gem.authors = ["Paul Rogers"]
22
+ gem.email = "paul@dingosky.com"
23
+ gem.homepage = "http://github.com/wcpr/riakrest"
24
+ gem.add_dependency('rest-client', '>= 1.0.0')
25
+ gem.add_development_dependency "rest-client", ">= 1.0.0"
26
+ gem.add_development_dependency "rspec", ">= 1.2.9"
27
+ end
28
+
29
+ Jeweler::GemcutterTasks.new
30
+
31
+ require 'spec/rake/spectask'
32
+ Spec::Rake::SpecTask.new(:spec) do |spec|
33
+ spec.libs << 'lib' << 'spec'
34
+ spec.spec_files = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
38
+ spec.libs << 'lib' << 'spec'
39
+ spec.pattern = 'spec/**/*_spec.rb'
40
+ spec.rcov = true
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :spec
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "riakrest #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -11,19 +11,14 @@ class Person
11
11
  group 'people'
12
12
  data_class PersonData
13
13
  auto_post true
14
+ auto_update true
14
15
  end
15
16
 
16
17
  remy = Person.new(:name => 'remy', :age => 10)
17
18
  puts Person.get('remy').name # => "remy"
18
19
 
19
20
  remy.name = "Remy"
20
- puts Person.get('remy').name # => "remy"
21
- remy.update
22
21
  puts Person.get('remy').name # => "Remy"
23
-
24
- Person.auto_update true
25
-
26
- puts Person.get('remy').age # => 10
27
22
  remy.age = 12
28
23
  puts Person.get('remy').age # => 12
29
24
 
@@ -45,6 +40,5 @@ remy.age = 10
45
40
  puts Person.get('remy').age # => 10
46
41
 
47
42
  remy.delete
48
- callie.delete
49
43
 
50
44
 
@@ -17,31 +17,31 @@ remy = Person.new(:name => 'remy', :age => 10)
17
17
  callie = Person.new(:name => 'Callie', :age => 12)
18
18
 
19
19
  remy.link(callie,'sister')
20
- puts remy.walk(Person,'sister').size # => 0
20
+ puts remy.query(Person,'sister').size # => 0
21
21
  remy.update
22
- puts remy.walk(Person,'sister').size # => 1
22
+ puts remy.query(Person,'sister').size # => 1
23
23
  remy.remove_link(callie,'sister')
24
24
 
25
25
  Person.auto_update true
26
26
  remy.link(callie,'sibling')
27
- puts remy.walk(Person,'sibling').size # => 1
27
+ puts remy.query(Person,'sibling').size # => 1
28
28
  remy.remove_link(callie,'sibling')
29
29
 
30
30
  callie.auto_update = false
31
31
  callie.link(remy,'sibling')
32
- puts callie.walk(Person,'sibling').size # => 0
32
+ puts callie.query(Person,'sibling').size # => 0
33
33
  callie.update
34
- puts callie.walk(Person,'sibling').size # => 1
34
+ puts callie.query(Person,'sibling').size # => 1
35
35
  callie.remove_link(remy,'sibling')
36
36
 
37
37
  Person.auto_update false
38
38
  remy.auto_update = true
39
39
  callie.auto_update = nil
40
40
  remy.bi_link(callie,'sisters')
41
- puts remy.walk(Person,'sisters').size # => 1
42
- puts callie.walk(Person,'sisters').size # => 0
41
+ puts remy.query(Person,'sisters').size # => 1
42
+ puts callie.query(Person,'sisters').size # => 0
43
43
  callie.update
44
- puts callie.walk(Person,'sisters').size # => 1
44
+ puts callie.query(Person,'sisters').size # => 1
45
45
 
46
46
  remy.delete
47
47
  callie.delete
@@ -11,23 +11,21 @@ remy = client.store(JiakObject.new(:bucket => bucket,
11
11
  :data => Person.new(:name => "remy",
12
12
  :age => 10)),
13
13
  :object => true)
14
- puts client.get(bucket,remy.key).data.name # => "remy"
15
-
16
- remy.data.name # => "remy"
17
- remy.data.name = "Remy"
18
- client.store(remy)
19
- puts client.get(bucket,remy.key).data.name # => "Remy"
20
-
21
-
22
14
  callie = client.store(JiakObject.new(:bucket => bucket,
23
15
  :data => Person.new(:name => "Callie",
24
16
  :age => 12)),
25
17
  :object => true)
26
- remy << JiakLink.new(bucket,callie.key,'sister')
18
+
19
+ puts client.get(bucket,remy.key).data.name # => "remy"
20
+
21
+ remy.data.name = "Remy"
22
+ remy << JiakLink.new(bucket,callie.key,'sister')
27
23
  client.store(remy)
28
24
 
25
+ puts client.get(bucket,remy.key).data.name # => "Remy"
26
+
29
27
  sisters = client.walk(bucket,remy.key,QueryLink.new(bucket,'sister'),Person)
30
- sisters[0].eql?(callie) # => true
28
+ puts sisters[0].eql?(callie) # => true
31
29
 
32
30
  client.delete(bucket,remy.key)
33
31
  client.delete(bucket,callie.key)
@@ -6,29 +6,27 @@ PersonData.keygen :name
6
6
 
7
7
  class Person
8
8
  include JiakResource
9
-
10
- server 'http://localhost:8002/jiak'
11
- group 'people'
12
- data_class PersonData
13
- auto_post true
9
+ server 'http://localhost:8002/jiak'
10
+ group 'people'
11
+ data_class PersonData
12
+ auto_post true
13
+ auto_update true
14
14
  end
15
15
 
16
- remy = Person.new(:name => 'remy', :age => 10)
17
- puts Person.get('remy').name # => "remy"
16
+ remy = Person.new(:name => 'remy',:age => 10) # (auto-post)
17
+ puts remy.name # => "remy" (auto-update)
18
+
19
+ puts Person.get('remy').name # => "remy" (from Jiak server)
20
+ puts Person.get('remy').age # => 10 (from Jiak server)
18
21
 
19
- remy.name = "Remy"
20
- remy.update
21
- puts remy.name # => "Remy"
22
- puts Person.get('remy').name # => "Remy"
22
+ remy.age = 11 # (auto-update)
23
+ puts Person.get('remy').age # => 11 (from Jiak server)
23
24
 
24
- callie = Person.new(:name => 'Callie', :age => 12)
25
- remy.bi_link(callie,'sister').update
26
- callie.update
25
+ callie = Person.new(:name => 'Callie', :age => 13)
26
+ remy.link(callie,'sister')
27
27
 
28
- sisters = remy.walk(Person,'sister')
29
- puts sisters[0].eql?(callie) # => true
28
+ sisters = remy.query(Person,'sister')
29
+ puts sisters[0].eql?(callie) # => true
30
30
 
31
31
  remy.delete
32
32
  callie.delete
33
-
34
-
@@ -1,3 +1,8 @@
1
+ require 'lib/riakrest'
2
+ include RiakRest
3
+
4
+ # CxINC Example doesn't do anything useful yet
5
+
1
6
  require 'date'
2
7
  class DogData # :nodoc:
3
8
  include JiakData
@@ -10,8 +10,9 @@ class Parent
10
10
  server 'http://localhost:8002/jiak'
11
11
  group 'parents'
12
12
  data_class PersonData
13
+ auto_post true
14
+ auto_update true
13
15
  end
14
-
15
16
  Child = Parent.copy(:group => 'children')
16
17
 
17
18
  # relationships
@@ -31,8 +32,12 @@ child_parents = parent_children.inject({}) do |build, (p,cs)|
31
32
  end
32
33
 
33
34
  # store data and relationships
35
+ Parent.auto_post false
36
+ Parent.auto_update false
37
+ Child.auto_post false
38
+ Child.auto_update false
34
39
  parent_children.each do |pname,cnames|
35
- p = Parent.new(:name => pname)
40
+ p = Parent.new(:name => pname).post
36
41
  cnames.each do |cname|
37
42
  begin
38
43
  c = Child.get(cname)
@@ -43,57 +48,54 @@ parent_children.each do |pname,cnames|
43
48
  c.put
44
49
  p.link(c,'child')
45
50
  end
46
- p.post
51
+ p.update
47
52
  end
53
+ Parent.auto_post true
54
+ Parent.auto_update true
55
+ Child.auto_post true
56
+ Child.auto_update true
48
57
 
49
58
  # retrieve parents
50
59
  parents = parent_children.keys.map {|p| Parent.get(p)}
51
60
  p0,p1,p2,p3 = parents
52
- p1.name # => 'p1'
61
+ puts p1.name # => 'p1'
53
62
 
54
63
  # retrieve children
55
64
  children = child_parents.keys.map {|c| Child.get(c)}
56
65
  c0,c1,c2,c3 = children
57
- c1.name # => 'c1'
66
+ puts c1.name # => 'c1'
58
67
 
59
68
  # retrieve parent children
60
- p0c,p1c,p2c,p3c = parents.map {|p| p.walk(Child,'child')}
61
- p2c[0].name # => 'c2' (not sorted, so could be 'c3')
69
+ p0c,p1c,p2c,p3c = parents.map {|p| p.query(Child,'child')}
70
+ puts p2c[0].name # => 'c2' (not sorted, could be 'c3')
62
71
 
63
72
  # retrieve children parents
64
- c0p,c1p,c2p,c3p = children.map {|c| c.walk(Parent,'parent')}
65
- c3p[0].name # => 'p3'
73
+ c0p,c1p,c2p,c3p = children.map {|c| c.query(Parent,'parent')}
74
+ puts c3p[0].name # => 'p3'
66
75
 
67
76
  # retrieve children siblings
68
77
  c0s,c1s,c2s,c3s = children.map do |c|
69
- c.walk(Parent,'parent',Child,'child').delete_if{|s| s.eql?(c)}
78
+ c.query(Parent,'parent',Child,'child').delete_if{|s| s.eql?(c)}
70
79
  end
71
- c3s[0].name # => 'c2'
80
+ puts c3s[0].name # => 'c2'
72
81
 
73
82
  # who is c3's step-sibling's other parent?
74
- c3sp = c3.walk(Parent,'parent',Child,'child',Parent,'parent')
83
+ c3sp = c3.query(Parent,'parent',Child,'child',Parent,'parent')
75
84
  c3p.each {|p| c3sp.delete_if{|sp| p.eql?(sp)}}
76
- c3sp[0].name # => "p1"
85
+ puts c3sp[0].name # => "p1"
77
86
 
78
87
  # add sibling links
79
88
  children.each do |c|
80
- siblings = c.walk(Parent,'parent',Child,'child').delete_if{|s| s.eql?(c)}
89
+ siblings = c.query(Parent,'parent',Child,'child').delete_if{|s| s.eql?(c)}
81
90
  siblings.each {|s| c.link(s,'sibling')}
82
91
  c.update
83
92
  end
84
- c1.walk(Child,'sibling').size # => 2
93
+ puts c1.query(Child,'sibling').size # => 2
85
94
 
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
95
  # some folks are odd, and others are normal
94
96
  parent_children.keys.each do |p|
95
97
  parent = Parent.get(p)
96
- p_children = parent.walk(Child,'child')
98
+ p_children = parent.query(Child,'child')
97
99
  p_children.each do |child|
98
100
  child.link(parent, p[1].to_i.odd? ? 'odd' : 'normal')
99
101
  child.update
@@ -102,12 +104,15 @@ parent_children.keys.each do |p|
102
104
  parent.update
103
105
  end
104
106
  # refresh parents and children variables
105
- parents.each {|p| p.get}
106
- children.each {|c| c.get}
107
+ parents.each {|p| p.refresh}
108
+ children.each {|c| c.refresh}
107
109
 
108
110
  # do any odd parents have normal children?
109
111
  op = parents.inject([]) do |build,parent|
110
- build << parent.walk(Child,'normal',Parent,'odd')
112
+ build << parent.query(Child,'normal',Parent,'odd')
111
113
  build.flatten.uniq
112
114
  end
113
- op[0].name # => 'p1'
115
+ puts op[0].name # => 'p1'
116
+
117
+ parents.each {|p| p.delete}
118
+ children.each {|c| c.delete}
@@ -0,0 +1,38 @@
1
+ require 'riakrest'
2
+ include RiakRest
3
+
4
+ # class with 10 fields
5
+ class Full
6
+ include JiakResource
7
+ server 'http://localhost:8002/jiak'
8
+ group 'fields'
9
+ data_class JiakDataHash.create (0...10).map {|n| "f#{n}".to_sym}
10
+ auto_post true
11
+ auto_update true
12
+ end
13
+
14
+ # copy of above, but no read/write fields, i.e., only links
15
+ LinksOnly = JiakDataHash.create Full.schema
16
+ LinksOnly.readwrite []
17
+ Links = Full.copy(:data_class => LinksOnly)
18
+
19
+ # populate two Full objects with (meaningless) stuff
20
+ Full.pov
21
+ full1,full2 =
22
+ ["full1","full2"].map {|o| Full.new(Full.schema.write_mask.inject({}) do |h,f|
23
+ h[f]="#{o.upcase}-#{f.hash}"
24
+ h
25
+ end)}
26
+
27
+ Links.pov
28
+ links1 = Links.get(full1.jiak.key)
29
+ links1.link(full2,'link')
30
+
31
+ Full.pov
32
+ full2.f1 = "new f1"
33
+
34
+ linked = full1.query(Full,'link')[0]
35
+ puts linked.f1 == full2.f1 # => true
36
+
37
+ full1.delete
38
+ full2.delete
@@ -178,6 +178,11 @@ module RiakRest
178
178
  begin
179
179
  uri = jiak_uri(bucket,key,req_params)
180
180
  resp = RestClient.get(uri, :accept => APP_JSON)
181
+
182
+ # puts
183
+ # puts "---CxDEBUG---"
184
+ # puts " #{resp}"
185
+
181
186
  JiakObject.from_jiak(JSON.parse(resp),bucket.data_class)
182
187
  rescue RestClient::ResourceNotFound => err
183
188
  raise JiakResourceNotFound, "failed get: #{err.message}"
@@ -89,19 +89,27 @@ module RiakRest
89
89
 
90
90
  # :call-seq:
91
91
  # allowed :f1, ..., :fn -> array
92
+ # allowed [:f1, ..., :fn] -> array
92
93
  #
93
94
  # Fields allowed in Jiak interactions. Returns an array of the allowed
94
95
  # fields.
95
96
  #
97
+ # The field <code>jiak</code> is reserved for RiakRest.
98
+ #
99
+ # Raise JiakDataException if the fields include <code>jiak</code>.
96
100
  def allowed(*fields)
97
- arr_fields = create_array(fields)
98
- fields.each {|field| attr_accessor field}
101
+ if(fields.include?(:jiak) || fields.include?('jiak'))
102
+ raise JiakDataException, "jiak field name reserved for RiakRest"
103
+ end
104
+ arr_fields = transform_fields(*fields)
105
+ arr_fields.each {|field| attr_accessor field}
99
106
  @schema = JiakSchema.new(arr_fields)
100
107
  arr_fields
101
108
  end
102
109
 
103
110
  # :call-seq:
104
111
  # required :f1, ..., :fn -> array
112
+ # required [:f1, ..., :fn] -> array
105
113
  #
106
114
  # Fields required during in Jiak interactions. Returns an array of the
107
115
  # required fields.
@@ -112,6 +120,7 @@ module RiakRest
112
120
 
113
121
  # :call-seq:
114
122
  # readable :f1, ..., :fn -> array
123
+ # readable [:f1, ..., :fn] -> array
115
124
  #
116
125
  # Fields returned by Jiak on retrieval. Returns an array of the fields in
117
126
  # the read mask.
@@ -122,6 +131,7 @@ module RiakRest
122
131
 
123
132
  # :call-seq:
124
133
  # writable :f1, ..., :fn -> arry
134
+ # writable [:f1, ..., :fn] -> arry
125
135
  #
126
136
  # Fields that can be written during Jiak interaction. Returns an array of
127
137
  # the fields in the write mask.
@@ -132,6 +142,7 @@ module RiakRest
132
142
 
133
143
  # :call-seq:
134
144
  # readwrite :f1, ..., :fn -> array
145
+ # readwrite [:f1, ..., :fn] -> array
135
146
  #
136
147
  # Set the read and write masks to the same fields. Returns an array of
137
148
  # the fields in the masks.
@@ -141,7 +152,7 @@ module RiakRest
141
152
  end
142
153
 
143
154
  def set_fields(which,*fields)
144
- arr_fields = create_array(fields)
155
+ arr_fields = transform_fields(*fields)
145
156
  check_allowed(arr_fields)
146
157
  @schema.send("#{which}=",arr_fields)
147
158
  arr_fields
@@ -181,21 +192,16 @@ module RiakRest
181
192
  # end
182
193
  # </code>
183
194
  #
184
- # Raise JiakDataException if not explicitly defined by user-defined data class.
195
+ # Raise JiakDataException if not explicitly defined by user-data class.
185
196
  def jiak_create(json)
186
197
  raise JiakDataException, "#{self} must define jiak_create"
187
198
  end
188
199
 
189
- def create_array(*fields)
190
- if(fields.size == 1 && fields[0].is_a?(Array))
191
- array = fields[0]
192
- else
193
- array = fields
194
- end
195
- array.map {|field| field}
196
- array
200
+ def transform_fields(*fields)
201
+ fields = fields[0] if(fields[0].is_a?(Array))
202
+ fields.map {|f| f.to_sym}
197
203
  end
198
- private :create_array
204
+ private :transform_fields
199
205
 
200
206
  def check_allowed(fields)
201
207
  allowed_fields = @schema.allowed_fields
@@ -132,7 +132,7 @@ module RiakRest
132
132
 
133
133
  # String representation of this QueryLink.
134
134
  def to_s
135
- '["'+@bucket+'","'+@tag+'","'+@acc+'"]'
135
+ "[#{bucket},#{tag},#{acc}]"
136
136
  end
137
137
 
138
138
  def transform_args(b,t,a)