Class: CyberCoach::Partnership
- Inherits:
-
Resource
- Object
- AbstractResource
- Resource
- CyberCoach::Partnership
- Includes:
- Pageable, PutCreateable
- Defined in:
- lib/cybercoach/partnership.rb
Overview
A Partnership consists of two Users, which participate in different Sport with Subscriptions, to which Entries are submitted.
Instance Attribute Summary collapse
-
#confirmed_by_proposed ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
-
#confirmed_by_proposer ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
-
#privacy_level ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
-
#proposed ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
-
#proposer ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
-
#subscriptions ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
Attributes inherited from Resource
Attributes inherited from AbstractResource
Instance Method Summary collapse
-
#from_serializable(serializable) ⇒ Object
:category: Serialization.
-
#plural_name ⇒ Object
:category: Configuration.
-
#singular_name ⇒ Object
:category: Configuration.
-
#to_serializable ⇒ Object
:category: Serialization.
Methods included from PutCreateable
Methods included from Pageable
Methods inherited from Resource
Methods inherited from AbstractResource
#deserialize, #initialize, #read, #resource_base_uri, #serialize
Constructor Details
This class inherits a constructor from CyberCoach::AbstractResource
Instance Attribute Details
#confirmed_by_proposed ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def confirmed_by_proposed @confirmed_by_proposed end |
#confirmed_by_proposer ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def confirmed_by_proposer @confirmed_by_proposer end |
#privacy_level ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def privacy_level @privacy_level end |
#proposed ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def proposed @proposed end |
#proposer ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def proposer @proposer end |
#subscriptions ⇒ Object
:attr: privacy_level The privacy level, see PrivacyLevel constants.
47 48 49 |
# File 'lib/cybercoach/partnership.rb', line 47 def subscriptions @subscriptions end |
Instance Method Details
#from_serializable(serializable) ⇒ Object
:category: Serialization
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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 |
#plural_name ⇒ Object
:category: Configuration
Returns ‘partnerships’.
133 134 135 |
# File 'lib/cybercoach/partnership.rb', line 133 def plural_name 'partnerships' end |
#singular_name ⇒ Object
:category: Configuration
Returns ‘partnership’.
124 125 126 |
# File 'lib/cybercoach/partnership.rb', line 124 def singular_name 'partnership' end |
#to_serializable ⇒ Object
:category: Serialization
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.
107 108 109 110 111 112 113 114 115 116 117 |
# 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 |