Class: Dawn::Drain

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

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method 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(data) ⇒ Drain

Returns a new instance of Drain.

Parameters:

  • options (Hash)


23
24
25
26
# File 'lib/dawn/api/models/drain.rb', line 23

def initialize(data)
  @app = nil
  @data = data
end

Instance Attribute Details

#appDawn::App

Returns:



31
32
33
# File 'lib/dawn/api/models/drain.rb', line 31

def app
  @app ||= App.find(id: app_id)
end

Class Method Details

.destroy(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})


68
69
70
71
72
73
74
75
# File 'lib/dawn/api/models/drain.rb', line 68

def self.destroy(options={})
  id = id_param(options)

  delete(
    path: "/drains/#{id}",
    query: options
  )
end

.find(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})


56
57
58
59
60
61
62
63
# File 'lib/dawn/api/models/drain.rb', line 56

def self.find(options={})
  id = id_param(options)

  new get(
    path: "/drains/#{id}",
    query: options
  )["drain"]
end

Instance Method Details

#destroy(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})


49
50
51
# File 'lib/dawn/api/models/drain.rb', line 49

def destroy(options={})
  Drain.destroy(options.merge(id: id))
end

#refreshself

Returns:

  • (self)


38
39
40
41
42
43
44
# File 'lib/dawn/api/models/drain.rb', line 38

def refresh
  @data = get(
    path: "/drains/#{id}",
    query: options
  )["drain"]
  self
end