Class: CoachClient::UserSubscription
- Inherits:
-
Subscription
- Object
- Resource
- Subscription
- CoachClient::UserSubscription
- Defined in:
- lib/coach_client/user_subscription.rb
Overview
A user subscription resource of the CyberCoach service.
Instance Attribute Summary collapse
- #datesubscribed ⇒ Integer readonly
- #id ⇒ Integer readonly
- #user ⇒ CoachClient::User
Attributes inherited from Subscription
#entries, #publicvisible, #sport
Attributes inherited from Resource
Class Method Summary collapse
-
.path ⇒ String
Returns the relative path to the user subscription resource.
Instance Method Summary collapse
-
#delete ⇒ true
Deletes the user subscription on the CyberCoach service.
-
#initialize(client, user, sport, publicvisible: nil) ⇒ CoachClient::UserSubscription
constructor
Creates a new user subscription.
-
#save ⇒ CoachClient::UserSubscription
Saves the user subscription to the CyberCoach service.
-
#to_s ⇒ String
Returns the string representation of the user subscription.
-
#update(size: 20, start: 0, all: false) ⇒ CoachClient::UserSubscription
Updates the user subscription with the data from the CyberCoach service.
-
#url ⇒ String
Returns the URL of the user subscription.
Methods inherited from Resource
Constructor Details
#initialize(client, user, sport, publicvisible: nil) ⇒ CoachClient::UserSubscription
Creates a new user subscription.
24 25 26 27 28 29 30 31 |
# File 'lib/coach_client/user_subscription.rb', line 24 def initialize(client, user, sport, publicvisible: nil) super(client, sport, publicvisible: publicvisible) @user = if user.is_a?(CoachClient::User) user else CoachClient::User.new(client, user) end end |
Instance Attribute Details
#datesubscribed ⇒ Integer (readonly)
5 6 7 |
# File 'lib/coach_client/user_subscription.rb', line 5 def datesubscribed @datesubscribed end |
#id ⇒ Integer (readonly)
5 6 7 |
# File 'lib/coach_client/user_subscription.rb', line 5 def id @id end |
#user ⇒ CoachClient::User
8 9 10 |
# File 'lib/coach_client/user_subscription.rb', line 8 def user @user end |
Class Method Details
.path ⇒ String
Returns the relative path to the user subscription resource.
13 14 15 |
# File 'lib/coach_client/user_subscription.rb', line 13 def self.path 'users/' end |
Instance Method Details
#delete ⇒ true
Deletes the user subscription on the CyberCoach service.
63 64 65 |
# File 'lib/coach_client/user_subscription.rb', line 63 def delete super(@user) end |
#save ⇒ CoachClient::UserSubscription
Saves the user subscription to the CyberCoach service.
The user subscription is created if it does not exist on the CyberCoach service, otherwise it tries to overwrite it.
54 55 56 |
# File 'lib/coach_client/user_subscription.rb', line 54 def save super(@user) end |
#to_s ⇒ String
Returns the string representation of the user subscription.
77 78 79 |
# File 'lib/coach_client/user_subscription.rb', line 77 def to_s "#{@user.username}/#{@sport}" end |
#update(size: 20, start: 0, all: false) ⇒ CoachClient::UserSubscription
Updates the user subscription with the data from the CyberCoach service.
40 41 42 |
# File 'lib/coach_client/user_subscription.rb', line 40 def update(size: 20, start: 0, all: false) super(@user, size: size, start: start, all: all) end |
#url ⇒ String
Returns the URL of the user subscription.
70 71 72 |
# File 'lib/coach_client/user_subscription.rb', line 70 def url "#{@user.url}/#{@sport}" end |