Class: Fog::Rackspace::Identity::User

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/identity/user.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#credentialsObject



42
43
44
45
46
47
48
49
# File 'lib/fog/rackspace/models/identity/user.rb', line 42

def credentials
  @credentials ||= begin
    Fog::Rackspace::Identity::Credentials.new({
      :service => service,
      :user => self
    })
  end
end

#destroyObject



27
28
29
30
31
# File 'lib/fog/rackspace/models/identity/user.rb', line 27

def destroy
  requires :identity
  service.delete_user(identity)
  true
end

#rolesObject



33
34
35
36
37
38
39
40
# File 'lib/fog/rackspace/models/identity/user.rb', line 33

def roles
  @roles ||= begin
    Fog::Rackspace::Identity::Roles.new({
      :service => service,
      :user => self
    })
  end
end

#saveObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/rackspace/models/identity/user.rb', line 16

def save
  requires :username, :email, :enabled
  unless persisted?
    data = service.create_user(username, email, enabled, :password => password)
  else
    data = service.update_user(identity, username, email, enabled, :password => password)
  end
  merge_attributes(data.body['user'])
  true
end