Class: LabClient::Key

Inherits:
Klass show all
Includes:
ClassHelpers
Defined in:
lib/labclient/keys/key.rb

Overview

Inspect Helper

Instance Attribute Summary

Attributes inherited from Klass

#client, #response

Attributes inherited from LabStruct

#response

Instance Method Summary collapse

Methods included from ClassHelpers

#has?, #keys, #raw

Methods inherited from Klass

#api_methods, #collect_project_id, #collect_release_id, #collect_repository_id, date_time_attrs, #format_time?, #group_name, #help, #initialize, #klass, #quiet?, #success?, #to_json, #update_self, user_attrs, #valid_group_project_levels, #verbose

Methods included from Docs

#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title

Methods included from CurlHelper

#curl

Methods included from Logger

#logger, logger, logger_setup

Methods inherited from LabStruct

#as_json, #client, #keys, #slice, #success?

Constructor Details

This class inherits a constructor from LabClient::Klass

Instance Method Details

#inspectObject



7
8
9
# File 'lib/labclient/keys/key.rb', line 7

def inspect
  "#<Key id: #{id}#{inspect_username}>"
end

#inspect_usernameObject



11
12
13
# File 'lib/labclient/keys/key.rb', line 11

def inspect_username
  ", username: #{@table[:user].username}" if has? :user
end

#userObject



15
16
17
18
19
20
21
22
# File 'lib/labclient/keys/key.rb', line 15

def user
  if has? :user
    LabClient::User.new(@table[:user], response, client)
  else
    user_id = collect_user_id
    client.users.show(user_id)
  end
end