Class: Coach4rb::Resource::Entity

Inherits:
Object
  • Object
show all
Includes:
Mixin::AsHash, Mixin::AutoConstructor, Mixin::Iterable, Enumerable
Defined in:
lib/coach4rb/resource/entity.rb

Direct Known Subclasses

Entry, Partnership, Sport, Subscription, User

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin::AsHash

included

Methods included from Mixin::Iterable

included

Methods included from Mixin::AutoConstructor

included

Instance Attribute Details

Returns the value of attribute links.



12
13
14
# File 'lib/coach4rb/resource/entity.rb', line 12

def links
  @links
end

#uriObject

Returns the value of attribute uri.



12
13
14
# File 'lib/coach4rb/resource/entity.rb', line 12

def uri
  @uri
end

Class Method Details

.from_coach(param) ⇒ Object



14
15
16
17
18
# File 'lib/coach4rb/resource/entity.rb', line 14

def self.from_coach(param)
  a_hash = param.dup
  a_hash[:links] ||= []
  self.new a_hash
end

Instance Method Details

#[](key) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/coach4rb/resource/entity.rb', line 29

def [](key)
  case key
    when Symbol
      super(key)
    else
      raise 'Error: param not supported!'
  end
end

#each(&block) ⇒ Object



21
22
23
24
25
26
# File 'lib/coach4rb/resource/entity.rb', line 21

def each(&block)
  instance_variables.each do |variable|
    value = instance_variable_get(variable)
    block.call variable, value
  end
end

#entity_pathObject



39
40
41
# File 'lib/coach4rb/resource/entity.rb', line 39

def entity_path
  raise 'Not implemented!'
end