Class: Riak::Link
- Inherits:
-
Object
- Object
- Riak::Link
- Includes:
- Util::Escape, Util::Translation
- Defined in:
- riak-client/lib/riak/link.rb
Overview
Represents a link from one object to another in Riak
Instance Attribute Summary (collapse)
-
- (String) bucket
The bucket of the related resource.
-
- (String) key
The key of the related resource.
-
- (String) tag
(also: #rel)
The relationship tag (or “rel”) of the other resource to this one.
Class Method Summary (collapse)
-
+ (Array<Link>) parse(header_string)
An array of Riak::Link structs parsed from the header.
Instance Method Summary (collapse)
- - (Object) ==(other)
- - (Boolean) eql?(other)
- - (Object) hash
-
- (Link) initialize(*args)
constructor
A new instance of Link.
- - (Object) inspect
- - (Object) to_s
- - (Object) to_walk_spec
-
- (String) url
The URL (relative or absolute) of the related resource.
- - (Object) url=(value)
Methods included from Util::Escape
Methods included from Util::Translation
Constructor Details
- (Link) initialize(url, tag) - (Link) initialize(bucket, key, tag)
A new instance of Link
55 56 57 58 59 60 61 62 |
# File 'riak-client/lib/riak/link.rb', line 55 def initialize(*args) raise ArgumentError unless (2..3).include?(args.size) if args.size == 2 self.url, @tag = args else @bucket, @key, @tag = args end end |
Instance Attribute Details
- (String) bucket
The bucket of the related resource
31 32 33 |
# File 'riak-client/lib/riak/link.rb', line 31 def bucket @bucket end |
- (String) key
The key of the related resource
34 35 36 |
# File 'riak-client/lib/riak/link.rb', line 34 def key @key end |
- (String) tag Also known as: rel
The relationship tag (or “rel”) of the other resource to this one
26 27 28 |
# File 'riak-client/lib/riak/link.rb', line 26 def tag @tag end |
Class Method Details
Instance Method Details
- (Object) ==(other)
89 90 91 |
# File 'riak-client/lib/riak/link.rb', line 89 def ==(other) other.is_a?(Link) && url == other.url && tag == other.tag end |
- (Boolean) eql?(other)
85 86 87 |
# File 'riak-client/lib/riak/link.rb', line 85 def eql?(other) self == other end |
- (Object) hash
81 82 83 |
# File 'riak-client/lib/riak/link.rb', line 81 def hash self.to_s.hash end |
- (Object) inspect
75 |
# File 'riak-client/lib/riak/link.rb', line 75 def inspect; to_s; end |
- (Object) to_s
77 78 79 |
# File 'riak-client/lib/riak/link.rb', line 77 def to_s %Q[<#{url}>; riaktag="#{tag}"] end |
- (Object) to_walk_spec
93 94 95 96 |
# File 'riak-client/lib/riak/link.rb', line 93 def to_walk_spec raise t("bucket_link_conversion") if tag == "up" || key.nil? WalkSpec.new(:bucket => bucket, :tag => tag) end |
- (String) url
The URL (relative or absolute) of the related resource
65 66 67 |
# File 'riak-client/lib/riak/link.rb', line 65 def url @url ||= "/riak/#{escape(bucket)}" + (key.blank? ? "" : "/#{escape(key)}") end |
- (Object) url=(value)
69 70 71 72 73 |
# File 'riak-client/lib/riak/link.rb', line 69 def url=(value) @url = value @bucket = unescape($1) if value =~ %r{^/[^/]+/([^/]+)/?} @key = unescape($1) if value =~ %r{^/[^/]+/[^/]+/([^/]+)/?} end |