Class: WTForum::User

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

Defined Under Namespace

Classes: NotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wtforum, attributes) ⇒ User

Returns a new instance of User.



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

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.



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

def apikey=(value)
  @apikey = value
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#field276177Object

Returns the value of attribute field276177.



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

def field276177
  @field276177
end

#field276178Object

Returns the value of attribute field276178.



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

def field276178
  @field276178
end

#field276179Object

Returns the value of attribute field276179.



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

def field276179
  @field276179
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#memberObject

Returns the value of attribute member.



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

def member
  @member
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#pw=(value) ⇒ Object (writeonly)

Sets the attribute pw

Parameters:

  • value

    the value to set the attribute pw to.



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

def pw=(value)
  @pw = value
end

#wtforumObject

Returns the value of attribute wtforum.



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

def wtforum
  @wtforum
end

Class Method Details

.create(wtforum, response, attributes) ⇒ Object



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

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



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

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

.update(wtforum, user_id, attributes) ⇒ Object



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

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

Instance Method Details

#aboutObject



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

def about
  field276179
end

#about=(value) ⇒ Object



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

def about= value
  self.field276179 = value
end

#destroyObject



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

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

#genderObject



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

def gender
  field276177
end

#gender=(value) ⇒ Object



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

def gender= value
  self.field276177 = value
end

#locationObject



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

def location
  field276178
end

#location=(value) ⇒ Object



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

def location= value
  self.field276178 = value
end

#save!Object



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

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



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

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

#usernameObject



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

def username
  member
end

#username=(value) ⇒ Object



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

def username= value
  self.member = value
end