Class: Pushbullet::Resource

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/pushbullet/resource.rb

Direct Known Subclasses

Channel, Contact, Device, Push

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject


7
8
9
10
11
# File 'lib/pushbullet/resource.rb', line 7

def self.all
  Pushbullet.client.get(path)[path].map do |model|
    new model
  end
end

.create(params) ⇒ Object


3
4
5
# File 'lib/pushbullet/resource.rb', line 3

def self.create(params)
  new Pushbullet.client.post(path, params)
end

.pathObject


23
24
25
26
# File 'lib/pushbullet/resource.rb', line 23

def self.path
  klass = self.is_a?(Class) ? self : self.class
  @path ||= "#{klass.to_s.demodulize.downcase}s"
end

Instance Method Details

#destroyObject


18
19
20
21
# File 'lib/pushbullet/resource.rb', line 18

def destroy
  Pushbullet.client.delete "#{self.class.path}/#{iden}"
  true
end

#save(params) ⇒ Object


13
14
15
16
# File 'lib/pushbullet/resource.rb', line 13

def save(params)
  Pushbullet.client.post "#{self.class.path}/#{iden}", params
  true
end