Class: Dawn::Domain

Inherits:
Object
  • Object
show all
Includes:
BaseApi
Defined in:
lib/dawn/api/models/domain.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) ⇒ Domain

Returns a new instance of Domain.

Parameters:

  • data (Hash)


23
24
25
26
# File 'lib/dawn/api/models/domain.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/domain.rb', line 31

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

Class Method Details

.destroy(options) ⇒ Object

Parameters:

  • options (Hash)


80
81
82
83
84
85
86
87
# File 'lib/dawn/api/models/domain.rb', line 80

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

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

.find(options) ⇒ Object

Parameters:

  • options (Hash)


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

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

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

.id_param(options) ⇒ Object

Parameters:

  • options (Hash)


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

def self.id_param(options)
  id = options.delete(:id) ||
  options.delete(:name) ||
  options.delete(:uri) ||
  options.delete(:url) ||
  raise
end

Instance Method Details

#destroy(options = {}) ⇒ Void

Parameters:

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

Returns:

  • (Void)


50
51
52
# File 'lib/dawn/api/models/domain.rb', line 50

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

#refreshself

Returns:

  • (self)


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

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