Class: CTM::User

Inherits:
Base
  • Object
show all
Defined in:
lib/ctm/user.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#account_id, #token

Instance Method Summary collapse

Methods inherited from Base

create, #release!

Constructor Details

#initialize(data, token = nil) ⇒ User

Returns a new instance of User.



10
11
12
13
14
15
16
17
# File 'lib/ctm/user.rb', line 10

def initialize(data, token=nil)
  super(data, token)
  @id         = data['id']
  @first_name = data['first_name']
  @last_name  = data['last_name']
  @email      = data['email']
  @role       = data['role']
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/ctm/user.rb', line 4

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



4
5
6
# File 'lib/ctm/user.rb', line 4

def first_name
  @first_name
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ctm/user.rb', line 3

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name.



4
5
6
# File 'lib/ctm/user.rb', line 4

def last_name
  @last_name
end

#roleObject

Returns the value of attribute role.



4
5
6
# File 'lib/ctm/user.rb', line 4

def role
  @role
end

Instance Method Details

#nameObject



6
7
8
# File 'lib/ctm/user.rb', line 6

def name
  "#{first_name} #{last_name}"
end

#saveObject



19
20
21
22
23
24
25
26
27
# File 'lib/ctm/user.rb', line 19

def save
  options = {
    :first_name => @first_name,
    :last_name => @last_name,
    :email => @email,
    :role => @role
  }
  super(options)
end