Class: WhenHub::EventsCollection
- Inherits:
-
Object
- Object
- WhenHub::EventsCollection
- Defined in:
- lib/whenhub/events_collection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #build(attributes = {}) ⇒ Object
- #create(attributes = {}) ⇒ Object
-
#initialize(client, schedule) ⇒ EventsCollection
constructor
A new instance of EventsCollection.
Constructor Details
#initialize(client, schedule) ⇒ EventsCollection
Returns a new instance of EventsCollection.
3 4 5 6 |
# File 'lib/whenhub/events_collection.rb', line 3 def initialize(client, schedule) @client = client @schedule = schedule end |
Instance Method Details
#all ⇒ Object
8 9 10 11 12 |
# File 'lib/whenhub/events_collection.rb', line 8 def all @client.get("/api/users/me/schedules/#{@schedule.id}/events").map do |attributes| Event.build(@client, @schedule, attributes) end end |
#build(attributes = {}) ⇒ Object
14 15 16 |
# File 'lib/whenhub/events_collection.rb', line 14 def build(attributes = {}) Event.build(@client, @schedule, attributes) end |
#create(attributes = {}) ⇒ Object
18 19 20 |
# File 'lib/whenhub/events_collection.rb', line 18 def create(attributes = {}) build(attributes).tap(&:save) end |