Class: Coach4rb::Resource::Subscription
- Inherits:
-
Entity
- Object
- Entity
- Coach4rb::Resource::Subscription
- Defined in:
- lib/coach4rb/resource/subscription.rb
Instance Attribute Summary (collapse)
-
- (Object) datesubscribed
(also: #created)
Returns the value of attribute datesubscribed.
-
- (Object) entries
Returns the value of attribute entries.
-
- (Object) id
Returns the value of attribute id.
-
- (Object) partnership
Returns the value of attribute partnership.
-
- (Object) publicvisble
(also: #visible)
Returns the value of attribute publicvisble.
-
- (Object) sport
Returns the value of attribute sport.
-
- (Object) uri
Returns the value of attribute uri.
Attributes inherited from Entity
Class Method Summary (collapse)
Instance Method Summary (collapse)
Methods inherited from Entity
Methods included from Mixin::AsHash
Methods included from Mixin::Iterable
Methods included from Mixin::AutoConstructor
Instance Attribute Details
- (Object) datesubscribed Also known as: created
Returns the value of attribute datesubscribed
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def datesubscribed @datesubscribed end |
- (Object) entries
Returns the value of attribute entries
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def entries @entries end |
- (Object) id
Returns the value of attribute id
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def id @id end |
- (Object) partnership
Returns the value of attribute partnership
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def partnership @partnership end |
- (Object) publicvisble Also known as: visible
Returns the value of attribute publicvisble
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def publicvisble @publicvisble end |
- (Object) sport
Returns the value of attribute sport
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def sport @sport end |
- (Object) uri
Returns the value of attribute uri
6 7 8 |
# File 'lib/coach4rb/resource/subscription.rb', line 6 def uri @uri end |
Class Method Details
+ (Object) from_coach(a_hash)
13 14 15 16 17 18 19 20 21 |
# File 'lib/coach4rb/resource/subscription.rb', line 13 def self.from_coach(a_hash) new_hash = a_hash.dup new_hash[:datesubscribed] = Time.at(a_hash[:datesubscribed]/1000).to_datetime rescue nil new_hash[:partnership] = Resource::Partnership.from_coach(new_hash[:partnership]) rescue nil new_hash[:user] = Resource::User.from_coach(new_hash[:user]) rescue nil new_hash[:entries] = new_hash[:entries].map {|a_hash| Resource::Entry.from_coach a_hash} rescue [] new_hash[:sport] = Resource::Sport.from_coach(new_hash[:sport]) rescue nil super new_hash end |
Instance Method Details
- (Object) entity_path
33 34 35 36 37 38 39 40 41 |
# File 'lib/coach4rb/resource/subscription.rb', line 33 def entity_path if @user "/users/#{@user.username}/#{@sport}" elsif @partnership "/partnerships/#{@partnership.first_user.username};#{@partnership.second_user.username}/#{@sport}" else raise 'Error: cannot create url!' end end |
- (Boolean) sport?(sport)
24 25 26 27 28 29 30 |
# File 'lib/coach4rb/resource/subscription.rb', line 24 def sport?(sport) raise 'Error: Invalid sport param!' if sport.nil? *, subscription_sport = uri.split('/') # get last part of the uri subscription_sport = subscription_sport.downcase.to_sym sport = sport.to_s.downcase.to_sym sport == subscription_sport end |