Class: Challonge::Participant
- Inherits:
-
API
- Object
- ActiveResource::Base
- API
- Challonge::Participant
show all
- Defined in:
- lib/challonge/participant.rb
Overview
the only attributes that will save are: name, seed, challonge_username, email, misc
Instance Method Summary
collapse
Methods inherited from API
key, key=, username, username=
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ Participant
Returns a new instance of Participant.
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/challonge/participant.rb', line 6
def initialize(attributes = {}, persisted = false)
@attributes = {}
@prefix_options = {}
@persisted = persisted
real_attributes = attributes.slice!(:tournament, :tournament_id, "tournament", "tournament_id")
load(real_attributes)
attributes.each_pair do |attr, val|
self.send("#{attr}=", val)
end
end
|
Instance Method Details
#name ⇒ Object
31
32
33
|
# File 'lib/challonge/participant.rb', line 31
def name
super ? super : @attributes["challonge_username"]
end
|
#randomize! ⇒ Object
27
28
29
|
# File 'lib/challonge/participant.rb', line 27
def randomize!
validated_post(:randomize)
end
|
#tournament ⇒ Object
19
20
21
|
# File 'lib/challonge/participant.rb', line 19
def tournament
Challonge::Tournament.find(self.prefix_options[:tournament_id])
end
|
#tournament=(tournament) ⇒ Object
23
24
25
|
# File 'lib/challonge/participant.rb', line 23
def tournament=(tournament)
self.prefix_options[:tournament_id] = tournament.id
end
|