Class: PollEverywhere::Models::Participant
- Inherits:
-
Object
- Object
- PollEverywhere::Models::Participant
- Includes:
- Serializable
- Defined in:
- lib/polleverywhere/models.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
Returns the value of attribute http.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #fetch ⇒ Object
-
#initialize(http = PollEverywhere.http) ⇒ Participant
constructor
A new instance of Participant.
- #path ⇒ Object
- #save ⇒ Object
Methods included from Serializable
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
#http ⇒ Object
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
#destroy ⇒ Object
40 41 42 43 |
# File 'lib/polleverywhere/models.rb', line 40 def destroy http.delete(path).response do |response| end end |
#fetch ⇒ Object
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 |
#path ⇒ Object
45 46 47 |
# File 'lib/polleverywhere/models.rb', line 45 def path "/participants/#{email}" end |
#save ⇒ Object
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 |