class CyberCoach::Sport

A Sport has Subscriptions to which Entries are submitted.

Attributes

description[RW]

The description.

name[RW]

The name.

subscriptions[RW]

:attr: subscriptions The Subscriptions to it.

Protected Instance Methods

initializable_with() click to toggle source
Calls superclass method CyberCoach::Resource#initializable_with
# File lib/cybercoach/sport.rb, line 104
def initializable_with
  super + [:name, :description]
end

Configuration

↑ top

Public Instance Methods

plural_name() click to toggle source

Returns ‘sports’.

# File lib/cybercoach/sport.rb, line 87
def plural_name
  'sports'
end
singular_name() click to toggle source

Returns ‘sport’.

# File lib/cybercoach/sport.rb, line 78
def singular_name
  'sport'
end

Invalidation

↑ top

Protected Instance Methods

invalidate_uri() click to toggle source

Sets the uri to the base uri and the name.

# File lib/cybercoach/sport.rb, line 98
def invalidate_uri
  unless @name.nil?
    @uri = "#{resource_base_uri}#{@name}/"
  end
end

Serialization

↑ top

Public Instance Methods

from_serializable(serializable) click to toggle source

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.

Calls superclass method CyberCoach::Resource#from_serializable
# 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
to_serializable() click to toggle source

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.

Calls superclass method CyberCoach::Resource#to_serializable
# File lib/cybercoach/sport.rb, line 66
def to_serializable
  serializable = super
  serializable['name'] = @name
  serializable['description'] = @description
  serializable
end