class Conjur::Id
Encapsulates a Conjur
id, which consists of account, kind, and identifier.
Attributes
id[R]
Public Class Methods
new(id)
click to toggle source
# File lib/conjur/id.rb, line 26 def initialize id @id = Id.normalize id end
normalize(id)
click to toggle source
# File lib/conjur/id.rb, line 64 def self.normalize id Array(id).join(':').tap do |id| raise ArgumentError, "id must be fully qualified: #{id}" \ unless id =~ /.*:.*:.*/ end end
Public Instance Methods
==(other)
click to toggle source
Defines id equivalence using the string representation.
Calls superclass method
# File lib/conjur/id.rb, line 39 def == other if other.is_a?(String) to_s == other else super end end
account()
click to toggle source
The organization account, obtained from the first component of the id.
# File lib/conjur/id.rb, line 31 def account; id.split(':', 3)[0]; end
as_json(options={})
click to toggle source
@return [String] the id string.
# File lib/conjur/id.rb, line 48 def as_json options={} @id end
identifier()
click to toggle source
The object identifier, obtained from the third component of the id. The identifier must be unique within the ‘account` and `kind`.
# File lib/conjur/id.rb, line 36 def identifier; id.split(':', 3)[2]; end
kind()
click to toggle source
The object kind, obtained from the second component of the id.
# File lib/conjur/id.rb, line 33 def kind; id.split(':', 3)[1]; end
to_s()
click to toggle source
@return [String] the id string
# File lib/conjur/id.rb, line 60 def to_s id end
to_url_path()
click to toggle source
Splits the id into 3 components, and then joins them with a forward-slash ‘/`.
# File lib/conjur/id.rb, line 53 def to_url_path id.split(':', 3) .map(&method(:fully_escape)) .join('/') end