Class: Coach4rb::Resource::User

Inherits:
Entity
  • Object
show all
Defined in:
lib/coach4rb/resource/user.rb

Instance Attribute Summary collapse

Attributes inherited from Entity

#links, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#[], #each

Methods included from Mixin::AsHash

included

Methods included from Mixin::Iterable

included

Methods included from Mixin::AutoConstructor

included

Instance Attribute Details

#datecreatedObject Also known as: created

Returns the value of attribute datecreated.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def datecreated
  @datecreated
end

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def email
  @email
end

#partnershipsObject

Returns the value of attribute partnerships.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def partnerships
  @partnerships
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def password
  @password
end

#publicvisibleObject Also known as: public_visible

Returns the value of attribute publicvisible.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def publicvisible
  @publicvisible
end

#realnameObject Also known as: real_name

Returns the value of attribute realname.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def realname
  @realname
end

#subscriptionsObject

Returns the value of attribute subscriptions.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def subscriptions
  @subscriptions
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/coach4rb/resource/user.rb', line 7

def username
  @username
end

Class Method Details

.from_coach(a_hash) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/coach4rb/resource/user.rb', line 16

def self.from_coach(a_hash)
  new_hash = a_hash.dup
  new_hash[:password] = nil # avoid having a star password
  new_hash[:partnerships] ||= []
  new_hash[:partnerships] = new_hash[:partnerships].map {|a_hash| Resource::Partnership.from_coach a_hash }
  new_hash[:subscriptions] ||= []
  new_hash[:subscriptions] = new_hash[:subscriptions].map {|a_hash| Resource::Subscription.from_coach a_hash }
  new_hash[:datecreated] = Time.at(new_hash[:datecreated]/1000).to_datetime rescue nil
  super(new_hash)
end

Instance Method Details

#entity_pathObject



28
29
30
# File 'lib/coach4rb/resource/user.rb', line 28

def entity_path
  "/users/#{username}"
end