Class: CyberCoach::Sport
- Inherits:
-
Resource
- Object
- AbstractResource
- Resource
- CyberCoach::Sport
- Includes:
- Pageable
- Defined in:
- lib/cybercoach/sport.rb
Overview
A Sport has Subscriptions to which Entries are submitted.
Instance Attribute Summary collapse
-
#description ⇒ Object
:attr: subscriptions The Subscriptions to it.
-
#name ⇒ Object
:attr: subscriptions The Subscriptions to it.
-
#subscriptions ⇒ Object
:attr: subscriptions The Subscriptions to it.
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 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
#description ⇒ Object
:attr: subscriptions The Subscriptions to it.
26 27 28 |
# File 'lib/cybercoach/sport.rb', line 26 def description @description end |
#name ⇒ Object
:attr: subscriptions The Subscriptions to it.
26 27 28 |
# File 'lib/cybercoach/sport.rb', line 26 def name @name end |
#subscriptions ⇒ Object
:attr: subscriptions The Subscriptions to it.
26 27 28 |
# File 'lib/cybercoach/sport.rb', line 26 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.
- name
-
The name.
- description
-
The description.
- subscriptions
-
Subscription serializables.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cybercoach/sport.rb', line 40 def from_serializable(serializable) super(serializable) @name = serializable['name'] @description = serializable['description'] @subscriptions = [] unless serializable['subscriptions'].nil? @subscriptions = serializable['subscriptions'].map do |subscription_serializable| subscription = Subscription.new subscription.from_serializable(subscription_serializable) subscription end end end |
#plural_name ⇒ Object
:category: Configuration
Returns ‘sports’.
87 88 89 |
# File 'lib/cybercoach/sport.rb', line 87 def plural_name 'sports' end |
#singular_name ⇒ Object
:category: Configuration
Returns ‘sport’.
78 79 80 |
# File 'lib/cybercoach/sport.rb', line 78 def singular_name 'sport' 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.
- name
-
The name.
- description
-
The description.
66 67 68 69 70 71 |
# File 'lib/cybercoach/sport.rb', line 66 def to_serializable serializable = super serializable['name'] = @name serializable['description'] = @description serializable end |