Class: Dawn::App::Drains

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseApi

included, #to_h

Methods included from BaseApi::RequestExtension

#request

Methods included from SafeExtension

#safe

Constructor Details

#initialize(app) ⇒ Drains

Returns a new instance of Drains.

Parameters:



15
16
17
# File 'lib/dawn/api/models/app/drains.rb', line 15

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

Instance Method Details

#all(options = {}) ⇒ Array<Dawn::Drain>

Returns:



48
49
50
51
52
53
# File 'lib/dawn/api/models/app/drains.rb', line 48

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

#create(options = {}) ⇒ Dawn::Drain

Returns:



36
37
38
39
40
41
42
43
# File 'lib/dawn/api/models/app/drains.rb', line 36

def create(options={})
  options.fetch(:drain)

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

#destroy(options) ⇒ Object



62
63
64
# File 'lib/dawn/api/models/app/drains.rb', line 62

def destroy(options)
  Drain.destroy(options)
end

#each({ |drain| do_stuff_with_drain }) ⇒ Object



29
30
31
# File 'lib/dawn/api/models/app/drains.rb', line 29

def each(&block)
  all.each(&block)
end

#find(options = {}) ⇒ Dawn::Drain

Returns:



58
59
60
# File 'lib/dawn/api/models/app/drains.rb', line 58

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

#to_aArray<Dawn::Drain>

Returns:



22
23
24
# File 'lib/dawn/api/models/app/drains.rb', line 22

def to_a
  all
end