Class: Dawn::App::Drains

Inherits:
Object
  • Object
show all
Includes:
BaseApi
Defined in:
lib/dawn/api/app/drains.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseApi

included

Methods included from BaseApi::Extension

#json_request, #request

Constructor Details

#initialize(app) ⇒ Drains

Returns a new instance of Drains.



12
13
14
# File 'lib/dawn/api/app/drains.rb', line 12

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'lib/dawn/api/app/drains.rb', line 10

def app
  @app
end

Instance Method Details

#all(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/dawn/api/app/drains.rb', line 25

def all(options={})
  json_request(
    expects: 200,
    method: :get,
    path: "/apps/#{app.id}/drains",
    query: options
  ).map { |hsh| Drain.new(hsh["drain"]).tap { |d| d.app = @app } }
end

#create(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/dawn/api/app/drains.rb', line 16

def create(options={})
  Drain.new(json_request(
    expects: 200,
    method: :post,
    path: "/apps/#{app.id}/drains",
    body: options.to_json
  )["drain"]).tap { |d| d.app = @app }
end

#find(options = {}) ⇒ Object



34
35
36
# File 'lib/dawn/api/app/drains.rb', line 34

def find(options={})
  Drain.find(options).tap { |d| d.app = @app }
end