Class: WTForum::User

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

Defined Under Namespace

Classes: NotFound, UsernameAlreadyTaken

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wtforum, attributes) ⇒ User

Returns a new instance of User.



21
22
23
24
# File 'lib/wtforum/user.rb', line 21

def initialize wtforum, attributes
  self.wtforum = wtforum
  self.attributes = attributes
end

Instance Attribute Details

#apikey=(value) ⇒ Object (writeonly)

Sets the attribute apikey

Parameters:

  • value

    the value to set the attribute apikey to.



57
58
59
# File 'lib/wtforum/user.rb', line 57

def apikey=(value)
  @apikey = value
end

#emailObject

Returns the value of attribute email.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def email
  @email
end

#field276177Object

Returns the value of attribute field276177.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def field276177
  @field276177
end

#field276178Object

Returns the value of attribute field276178.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def field276178
  @field276178
end

#field276179Object

Returns the value of attribute field276179.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def field276179
  @field276179
end

#idObject

Returns the value of attribute id.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def id
  @id
end

#memberObject

Returns the value of attribute member.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def member
  @member
end

#nameObject

Returns the value of attribute name.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def name
  @name
end

#pw=(value) ⇒ Object (writeonly)

Sets the attribute pw

Parameters:

  • value

    the value to set the attribute pw to.



57
58
59
# File 'lib/wtforum/user.rb', line 57

def pw=(value)
  @pw = value
end

#wtforumObject

Returns the value of attribute wtforum.



56
57
58
# File 'lib/wtforum/user.rb', line 56

def wtforum
  @wtforum
end

Class Method Details

.create(wtforum, response, attributes) ⇒ Object



6
7
8
9
10
# File 'lib/wtforum/user.rb', line 6

def self.create wtforum, response, attributes
  user_id = WTForum.extract_value(:userid, from: response.body)
  attributes[:id] = user_id.to_i
  new(wtforum, attributes)
end

.destroy(wtforum, user_id) ⇒ Object



16
17
18
19
# File 'lib/wtforum/user.rb', line 16

def self.destroy wtforum, user_id
  wtforum.destroy_user(user_id)
  true
end

.update(wtforum, user_id, attributes) ⇒ Object



12
13
14
# File 'lib/wtforum/user.rb', line 12

def self.update wtforum, user_id, attributes
  wtforum.find_user(user_id).update_attributes!(attributes)
end

Instance Method Details

#aboutObject



83
84
85
# File 'lib/wtforum/user.rb', line 83

def about
  field276179
end

#about=(value) ⇒ Object



87
88
89
# File 'lib/wtforum/user.rb', line 87

def about= value
  self.field276179 = value
end

#destroyObject



52
53
54
# File 'lib/wtforum/user.rb', line 52

def destroy
  self.class.destroy self.wtforum, id
end

#genderObject



67
68
69
# File 'lib/wtforum/user.rb', line 67

def gender
  field276177
end

#gender=(value) ⇒ Object



71
72
73
# File 'lib/wtforum/user.rb', line 71

def gender= value
  self.field276177 = value
end

#locationObject



75
76
77
# File 'lib/wtforum/user.rb', line 75

def location
  field276178
end

#location=(value) ⇒ Object



79
80
81
# File 'lib/wtforum/user.rb', line 79

def location= value
  self.field276178 = value
end

#save!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/wtforum/user.rb', line 31

def save!
  wtforum.edit_user(id).tap do |page|
    form = page.forms.first
    form["name"] = name
    form["field276177"] = field276177
    form["field276178"] = field276178
    form["field276179"] = field276179
    form.submit
  end
  wtforum.edit_user_username(id).tap do |page|
    form = page.forms.first
    form["new_username"] = username
    form.submit
  end
  wtforum.edit_user_email(id).tap do |page|
    form = page.forms.first
    form["email"] = email
    form.submit
  end
end

#update_attributes!(attributes) ⇒ Object



26
27
28
29
# File 'lib/wtforum/user.rb', line 26

def update_attributes! attributes
  self.attributes = attributes
  save!
end

#usernameObject



59
60
61
# File 'lib/wtforum/user.rb', line 59

def username
  member
end

#username=(value) ⇒ Object



63
64
65
# File 'lib/wtforum/user.rb', line 63

def username= value
  self.member = value
end