Class: Conjur::BaseObject

Inherits:
Object
  • Object
show all
Includes:
BuildObject, Cast, LogSource, Routing
Defined in:
lib/conjur/base_object.rb

Direct Known Subclasses

Group, Host, HostFactory, Layer, Policy, Resource, Role, User, Variable, Webservice

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Routing

#parser_for, #url_for

Methods included from BuildObject

#build_object

Methods included from LogSource

#log

Constructor Details

#initialize(id, credentials) ⇒ BaseObject

Returns a new instance of BaseObject.



33
34
35
36
# File 'lib/conjur/base_object.rb', line 33

def initialize id, credentials
  @id = cast_to_id(id)
  @credentials = credentials
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



31
32
33
# File 'lib/conjur/base_object.rb', line 31

def credentials
  @credentials
end

#idObject (readonly)

Returns the value of attribute id.



31
32
33
# File 'lib/conjur/base_object.rb', line 31

def id
  @id
end

Instance Method Details

#accountObject



44
# File 'lib/conjur/base_object.rb', line 44

def ; id.; end

#as_json(options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/conjur/base_object.rb', line 38

def as_json options={}
  {
    id: id.to_s
  }
end

#identifierObject



46
# File 'lib/conjur/base_object.rb', line 46

def identifier; id.identifier; end

#kindObject



45
# File 'lib/conjur/base_object.rb', line 45

def kind; id.kind; end

#usernameObject



48
49
50
# File 'lib/conjur/base_object.rb', line 48

def username
  credentials[:username] or raise "No username found in credentials"
end