Class: Ubiquitously::Base::User

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization, ActiveModel::Validations, Resourceful
Defined in:
lib/ubiquitously/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Resourceful

included

Constructor Details

#initialize(attributes = {}) ⇒ User

Returns a new instance of User.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ubiquitously/base.rb', line 12

def initialize(attributes = {})
  attributes = attributes.symbolize_keys
  
  attributes[:username] ||= Ubiquitously.key("#{service_name}.key")
  attributes[:password] ||= Ubiquitously.key("#{service_name}.secret")
  
  @logged_in = false
  
  super(attributes)
  
  self.agent = Mechanize.new
  # self.agent.log = Logger.new(STDOUT)
  self.agent.user_agent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; ru-ru) AppleWebKit/533.2+ (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10"
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



8
9
10
# File 'lib/ubiquitously/base.rb', line 8

def agent
  @agent
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/ubiquitously/base.rb', line 8

def password
  @password
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/ubiquitously/base.rb', line 8

def username
  @username
end

Instance Method Details

#logged_in?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ubiquitously/base.rb', line 27

def logged_in?
  @logged_in == true
end