Class: WTForum::Session

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wtforum, token) ⇒ Session

Returns a new instance of Session.



14
15
16
17
# File 'lib/wtforum/session.rb', line 14

def initialize wtforum, token
  @wtforum = wtforum
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



19
20
21
# File 'lib/wtforum/session.rb', line 19

def token
  @token
end

#wtforumObject (readonly)

Returns the value of attribute wtforum.



19
20
21
# File 'lib/wtforum/session.rb', line 19

def wtforum
  @wtforum
end

Class Method Details

.create(wtforum, response) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/wtforum/session.rb', line 3

def self.create wtforum, response
  auth_token = WTForum.extract_value(:authtoken, from: response.body)
  new(wtforum, auth_token)
rescue WTForumError => e
  if e.message == "Error: The specified user does not exist."
    raise WTForum::User::NotFound
  else
    raise
  end
end

Instance Method Details

#auth_token_image_urlObject



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

def auth_token_image_url
  "http://#{wtforum.domain}/register/dologin?authtoken=#{token}"
end