Class: Brightbox::User
- Inherits:
-
Api
- Object
- Api
- Brightbox::User
show all
- Defined in:
- lib/bbcloud/users.rb
Instance Attribute Summary
Attributes inherited from Api
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Api
cache_all!, cached_get, conn, #exists?, find, find_by_handle, #fog_model, #initialize, #method_missing
Constructor Details
This class inherits a constructor from Brightbox::Api
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Brightbox::Api
Class Method Details
.all ⇒ Object
12
13
14
|
# File 'lib/bbcloud/users.rb', line 12
def self.all
conn.users
end
|
.default_field_order ⇒ Object
21
22
23
|
# File 'lib/bbcloud/users.rb', line 21
def self.default_field_order
[:id, :name, :email_address, :accounts]
end
|
.get(id) ⇒ Object
16
17
18
19
|
# File 'lib/bbcloud/users.rb', line 16
def self.get(id)
u = conn.users.get id
(u.nil? or u.id != id) ? nil : u
end
|
Instance Method Details
#accounts ⇒ Object
25
26
27
|
# File 'lib/bbcloud/users.rb', line 25
def accounts
@accounts ||= fog_model.accounts.collect { |a| Account.new(a["id"]) }
end
|
#attributes ⇒ Object
4
5
6
|
# File 'lib/bbcloud/users.rb', line 4
def attributes
fog_model.attributes
end
|
#render_cell ⇒ Object
43
44
45
|
# File 'lib/bbcloud/users.rb', line 43
def render_cell
handle if fog_model
end
|
#save ⇒ Object
33
34
35
36
37
|
# File 'lib/bbcloud/users.rb', line 33
def save
fog_model.save
rescue Excon::Errors::UnprocessableEntity
raise InvalidRecord, "Could not save user #{self.id}"
end
|
#ssh_key_set? ⇒ Boolean
39
40
41
|
# File 'lib/bbcloud/users.rb', line 39
def ssh_key_set?
!ssh_key.to_s.strip.empty?
end
|
#to_row ⇒ Object
8
9
10
|
# File 'lib/bbcloud/users.rb', line 8
def to_row
attributes.merge({ :accounts => accounts.size })
end
|
#to_s ⇒ Object
29
30
31
|
# File 'lib/bbcloud/users.rb', line 29
def to_s
@id
end
|