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

- (Object) datecreated 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

- (Object) email

Returns the value of attribute email



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

def email
  @email
end

- (Object) partnerships

Returns the value of attribute partnerships



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

def partnerships
  @partnerships
end

- (Object) password

Returns the value of attribute password



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

def password
  @password
end

- (Object) publicvisible 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

- (Object) realname 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

- (Object) subscriptions

Returns the value of attribute subscriptions



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

def subscriptions
  @subscriptions
end

- (Object) username

Returns the value of attribute username



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

def username
  @username
end

Class Method Details

+ (Object) from_coach(a_hash)



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

- (Object) entity_path



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

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