Class: CFoundry::V2::User

Inherits:
Model
  • Object
show all
Defined in:
lib/cfoundry/v2/user.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#cache, #changes, #created_at, #diff, #updated_at

Attributes included from ModelMagic

#scoped_organization, #scoped_space

Instance Method Summary collapse

Methods inherited from Model

#attribute_for_error, #changed?, #create, #create!, #create_endpoint_name, #delete, #eql?, #exists?, #hash, inherited, #initialize, #inspect, #invalidate!, #manifest, #object_name, objects, #partial?, #persisted?, #plural_object_name, #query_target, #to_key, #to_param, #update!

Methods included from ModelMagic

#attributes, #defaults, #inherited, #object_name, params_from, #plural_object_name, query_from_hash, #scoped_to_organization, #scoped_to_space, #to_many_relations, #to_one_relations

Methods included from ModelMagic::QueryableBy

#queryable_by

Methods included from ModelMagic::ToMany

#to_many

Methods included from ModelMagic::ToOne

#to_one

Methods included from ModelMagic::Attribute

#attribute

Methods included from ModelMagic::HasSummary

#has_summary

Methods included from ModelMagic::ClientExtensions

#add_client_methods

Constructor Details

This class inherits a constructor from CFoundry::V2::Model

Instance Attribute Details

#emailsObject

optional metadata from UAA



40
41
42
# File 'lib/cfoundry/v2/user.rb', line 40

def emails
  @emails
end

#nameObject

optional metadata from UAA



40
41
42
# File 'lib/cfoundry/v2/user.rb', line 40

def name
  @name
end

Instance Method Details

#change_password!(new, old) ⇒ Object



35
36
37
# File 'lib/cfoundry/v2/user.rb', line 35

def change_password!(new, old)
  @client.base.uaa.change_password(@guid, new, old)
end

#delete!(options = {}) ⇒ Object



72
73
74
75
76
# File 'lib/cfoundry/v2/user.rb', line 72

def delete! (options = {})
  super(options)
  @client.base.uaa.delete_user(guid)
  true
end

#emailObject



42
43
44
45
46
47
48
# File 'lib/cfoundry/v2/user.rb', line 42

def email
  # if the email collection is nil or empty? collect from UAA
  get_meta_from_uaa if @emails.nil?

  return unless @emails && @emails.first
  @emails.first[:value]
end

#family_nameObject



57
58
59
60
61
62
# File 'lib/cfoundry/v2/user.rb', line 57

def family_name
  get_meta_from_uaa if @name.nil?

  return unless @name && @name[:familyName] != email
  @name[:familyName]
end

#full_nameObject



64
65
66
67
68
69
70
# File 'lib/cfoundry/v2/user.rb', line 64

def full_name
  if @name && @name[:fullName]
    @name[:fullName]
  elsif given_name && family_name
    "#{given_name} #{family_name}"
  end
end

#given_nameObject



50
51
52
53
54
55
# File 'lib/cfoundry/v2/user.rb', line 50

def given_name
  get_meta_from_uaa if @name.nil?

  return unless @name && @name[:givenName] != email
  @name[:givenName]
end

#guidObject



22
23
24
# File 'lib/cfoundry/v2/user.rb', line 22

def guid
  @guid
end

#guid=(x) ⇒ Object



28
29
30
31
# File 'lib/cfoundry/v2/user.rb', line 28

def guid=(x)
  @guid = x
  set_guid_attribute(x)
end

#set_guid_attributeObject



26
# File 'lib/cfoundry/v2/user.rb', line 26

alias set_guid_attribute guid=