Class: Dawn::App::Gears

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

Returns a new instance of Gears.



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

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

#create(options = {}) ⇒ Object



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

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

#find(options = {}) ⇒ Object



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

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

#restart(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/dawn/api/app/gears.rb', line 38

def restart(options={})
  request(
    expects: 200,
    method: :post,
    path: "/apps/#{app.id}/gears/restart",
    body: options.to_json
  )
end