Class: Dawn::App::Domains

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

Returns a new instance of Domains.



12
13
14
# File 'lib/dawn/api/app/domains.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/domains.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/domains.rb', line 25

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

#create(options = {}) ⇒ Object



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

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

#find(options = {}) ⇒ Object



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

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