class CyberCoach::Partnership
A Partnership
consists of two Users, which participate in different Sport
with Subscriptions, to which Entries are submitted.
Attributes
True if the proposed User
has confirmed it, false otherwise.
True if the proposing User
has confirmed it, false otherwise.
:attr: privacy_level
The privacy level, see PrivacyLevel
constants.
The User
it is proposed to.
The User
who proposed it.
The Subscriptions.
Protected Instance Methods
# File lib/cybercoach/partnership.rb, line 151 def initializable_with super + [:proposer, :proposed, :privacy_level] end
Configuration
↑ topPublic Instance Methods
Returns ‘partnerships’.
# File lib/cybercoach/partnership.rb, line 133 def plural_name 'partnerships' end
Returns ‘partnership’.
# File lib/cybercoach/partnership.rb, line 124 def singular_name 'partnership' end
Invalidation
↑ topProtected Instance Methods
Sets the uri to the base uri and the proposer’s and proposed’s username if neither of them is nil.
# File lib/cybercoach/partnership.rb, line 145 def invalidate_uri unless @proposer.nil? || @proposed.nil? @uri = "#{resource_base_uri}#{@proposer.username};#{@proposed.username}/" end end
Serialization
↑ topPublic Instance Methods
Creates itself from a serializable representation, which only contains simple data types.
- serializable
-
A hash with the keys:
- uri
-
The URI.
- id
-
The identifier.
- user1
-
A
User
serializable of the proposer.
- user2
-
A
User
serializable of the proposed.
- subscriptions
-
Subscription
serializables.
- userconfirmed1
-
True if the proposing
User
has confirmed it, false otherwise.
- userconfirmed2
-
True if the proposed
User
has confirmed it, false otherwise.
- publicvisible
-
The privacy level, see
PrivacyLevel
constants.
# File lib/cybercoach/partnership.rb, line 69 def from_serializable(serializable) super(serializable) @proposer = nil unless serializable['user1'].nil? @proposer = User.new @proposer.from_serializable(serializable['user1']) end @proposed = nil unless serializable['user2'].nil? @proposed = User.new @proposed.from_serializable(serializable['user2']) end @subscriptions = [] unless serializable['subscriptions'].nil? @subscriptions = serializable['subscriptions'].map do |subscription_serializable| subscription = Subscription.new subscription.from_serializable(subscription_serializable) subscription end end @confirmed_by_proposer = serializable['userconfirmed1'] @confirmed_by_proposed = serializable['userconfirmed2'] @privacy_level = serializable['publicvisible'] end
Returns a serializable representation, which only contains simple data types. The hash has the keys:
- uri
-
The URI.
- id
-
The identifier.
- user1
-
A
User
serializable of the proposer.
- user2
-
A
User
serializable of the proposed.
- publicvisible
-
The privacy level, see
PrivacyLevel
constants.
# File lib/cybercoach/partnership.rb, line 107 def to_serializable serializable = super unless @proposer.nil? serializable['user1'] = @proposer.to_serializable end unless @proposed.nil? serializable['user2'] = @proposed.to_serializable end serializable['publicvisible'] = @privacy_level serializable end