Class: Conjur::BaseObject

Inherits:
Object
  • Object
show all
Includes:
BuildObject, Cast, LogSource
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 BuildObject

#build_object

Methods included from LogSource

#log

Constructor Details

#initialize(id, credentials) ⇒ BaseObject

Returns a new instance of BaseObject.



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

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

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



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

def credentials
  @credentials
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#accountObject



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

def ; id.; end

#as_json(options = {}) ⇒ Object



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

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

#identifierObject



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

def identifier; id.identifier; end

#kindObject



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

def kind; id.kind; end

#usernameObject



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

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