Class: Yammer::User
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.create(email) ⇒ Object
Creates a new user from email address.
-
.current ⇒ Object
Returns authenticated user's details.
Instance Method Summary collapse
-
#email ⇒ Object
Returns user's primary email.
-
#followers ⇒ Object
Returns all user's follwing this user.
-
#following ⇒ Object
Returns all users that this user is following.
-
#update!(params) ⇒ Object
Updates the user attributes.
Methods inherited from Base
#api_handler, attr_accessor_deffered, base_name, #base_name, #changes, #delete!, fetch, get, identity_map, #initialize, #load!, #load_deferred_attribute!, #loaded?, model_attributes, #modified?, #new_record?, #persisted?, #reload!, #save, #update
Methods included from ApiHandler
#api_handler, #establish_api_handler
Constructor Details
This class inherits a constructor from Yammer::Base
Class Method Details
.create(email) ⇒ Object
Creates a new user from email address
15 16 17 18 19 20 |
# File 'lib/yammer/user.rb', line 15 def self.create(email) result = api_handler.create_user(:email => email) return nil unless result.created? id = result.headers[:location].split('/').last.to_i new(:id => id) end |
.current ⇒ Object
Returns authenticated user's details
7 8 9 10 11 |
# File 'lib/yammer/user.rb', line 7 def self.current result = api_handler.current_user return nil unless result.success? new(result.body) end |
Instance Method Details
#email ⇒ Object
Returns user's primary email
30 31 32 33 34 35 36 |
# File 'lib/yammer/user.rb', line 30 def email @email ||= begin self.contact[:email_addresses].map do |e| e[:address] if e[:type] == 'primary' end.first end end |
#followers ⇒ Object
Returns all user's follwing this user
44 45 46 |
# File 'lib/yammer/user.rb', line 44 def followers api_handler.users_following(@id) end |
#following ⇒ Object
Returns all users that this user is following
39 40 41 |
# File 'lib/yammer/user.rb', line 39 def following api_handler.users_followed_by(@id) end |
#update!(params) ⇒ Object
Updates the user attributes
49 50 51 |
# File 'lib/yammer/user.rb', line 49 def update!(params) api_handler.update_user(@id, params) end |