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.
42 43 44 |
# File 'lib/polleverywhere/models.rb', line 42 def initialize(http=PollEverywhere.http) self.http = http end |
Instance Attribute Details
#http ⇒ Object
Returns the value of attribute http.
40 41 42 |
# File 'lib/polleverywhere/models.rb', line 40 def http @http end |
Class Method Details
.get(email) ⇒ Object
53 54 55 |
# File 'lib/polleverywhere/models.rb', line 53 def self.get(email) from_hash(:email => email).fetch end |
Instance Method Details
#destroy ⇒ Object
57 58 59 60 |
# File 'lib/polleverywhere/models.rb', line 57 def destroy http.delete.from(path).response do |response| end end |
#fetch ⇒ Object
66 67 68 69 70 |
# File 'lib/polleverywhere/models.rb', line 66 def fetch http.get.from(path).as(:json).response do |response| from_json response.body end end |
#path ⇒ Object
62 63 64 |
# File 'lib/polleverywhere/models.rb', line 62 def path "/participants/#{prop(:email).was || prop(:email).is}" end |
#save ⇒ Object
46 47 48 49 50 51 |
# File 'lib/polleverywhere/models.rb', line 46 def save http.put(to_json).as(:json).to(path).response do |response| value_set.commit from_json response.body end end |