Class: PollEverywhere::Models::Participant

Inherits:
Object
  • Object
show all
Includes:
Serializable
Defined in:
lib/polleverywhere/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Serializable

included

Constructor Details

#initialize(http = PollEverywhere.http) ⇒ Participant

Returns a new instance of Participant.



26
27
28
# File 'lib/polleverywhere/models.rb', line 26

def initialize(http=PollEverywhere.http)
  self.http = http
end

Instance Attribute Details

#httpObject

Returns the value of attribute http.



24
25
26
# File 'lib/polleverywhere/models.rb', line 24

def http
  @http
end

Class Method Details

.get(email) ⇒ Object



36
37
38
# File 'lib/polleverywhere/models.rb', line 36

def self.get(email)
  from_hash(:email => email).fetch
end

Instance Method Details

#destroyObject



40
41
42
43
# File 'lib/polleverywhere/models.rb', line 40

def destroy
  http.delete(path).response do |response|
  end
end

#fetchObject



49
50
51
52
53
# File 'lib/polleverywhere/models.rb', line 49

def fetch
  http.get.from(path).as(:json).response do |response|
    from_json response.body
  end
end

#pathObject



45
46
47
# File 'lib/polleverywhere/models.rb', line 45

def path
  "/participants/#{email}"
end

#saveObject



30
31
32
33
34
# File 'lib/polleverywhere/models.rb', line 30

def save
  http.put(to_json).as(:json).to(path).response do |response|
    from_json response.body
  end
end