Class: Riak::WalkSpec
- Extended by:
- Util::Translation
- Includes:
- Util::Escape, Util::Translation
- Defined in:
- lib/riak/walk_spec.rb
Overview
The specification of how to follow links from one object to another in Riak, when using the link-walker resource. Example link-walking operation:
GET /riak/artists/REM/albums,_,_/tracks,_,1
This operation would have two WalkSpecs:
Riak::WalkSpec.new({:bucket => 'albums'})
Riak::WalkSpec.new({:bucket => 'tracks', :result => true})
Instance Attribute Summary collapse
-
#bucket ⇒ String
The bucket followed links should be restricted to.
-
#keep ⇒ Boolean
Whether objects should be returned from this phase of link walking.
-
#tag ⇒ String
The “riaktag” or “rel” that followed links should be restricted to.
Class Method Summary collapse
-
.normalize(*params) ⇒ Object
Normalize a list of walk specs into WalkSpec objects.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
-
#initialize(*args) ⇒ WalkSpec
constructor
Creates a walk-spec for use in finding other objects in Riak.
-
#to_s ⇒ Object
Converts the walk-spec into the form required by the link-walker resource URL.
Methods included from Util::Translation
Methods included from Util::Escape
#escape, #maybe_escape, #maybe_unescape, #unescape
Constructor Details
#initialize(hash) ⇒ WalkSpec #initialize(bucket, tag, keep) ⇒ WalkSpec
Creates a walk-spec for use in finding other objects in Riak.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/riak/walk_spec.rb', line 69 def initialize(*args) args.flatten! case args.size when 1 assign_from_hash args.first when 3 assign(*args) else fail ArgumentError, t('wrong_argument_count_walk_spec') end end |
Instance Attribute Details
#bucket ⇒ String
Returns The bucket followed links should be restricted to. “_” represents all buckets.
24 25 26 |
# File 'lib/riak/walk_spec.rb', line 24 def bucket @bucket end |
#keep ⇒ Boolean
Returns Whether objects should be returned from this phase of link walking. Default is false.
32 33 34 |
# File 'lib/riak/walk_spec.rb', line 32 def keep @keep end |
#tag ⇒ String
Returns The “riaktag” or “rel” that followed links should be restricted to. “_” represents all tags.
28 29 30 |
# File 'lib/riak/walk_spec.rb', line 28 def tag @tag end |
Class Method Details
.normalize(*params) ⇒ Object
Normalize a list of walk specs into WalkSpec objects.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/riak/walk_spec.rb', line 35 def self.normalize(*params) params.flatten! specs = [] while params.length > 0 case param = params.shift when Hash specs << new(param) when WalkSpec specs << param else normalize_long_params specs, params, param end end specs end |
Instance Method Details
#==(other) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/riak/walk_spec.rb', line 89 def ==(other) return false unless other.is_a? WalkSpec return false unless other.bucket == bucket return false unless other.tag == tag return false unless other.keep == keep true end |
#===(other) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/riak/walk_spec.rb', line 97 def ===(other) return true if self == other case other when WalkSpec walkspec_threequality(other) when Link link_threequality(other) end end |
#to_s ⇒ Object
Converts the walk-spec into the form required by the link-walker resource URL
83 84 85 86 87 |
# File 'lib/riak/walk_spec.rb', line 83 def to_s b = @bucket && escape(@bucket) || '_' t = @tag && escape(@tag) || '_' "#{b},#{t},#{@keep ? '1' : '_'}" end |