Class: Refocus::Aspects

Inherits:
Object
  • Object
show all
Includes:
JsonHelper, PathHelper
Defined in:
lib/refocus/aspects.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathHelper

#parent_and_name

Methods included from JsonHelper

#json

Constructor Details

#initialize(url:, token:) ⇒ Aspects

Returns a new instance of Aspects.



12
13
14
# File 'lib/refocus/aspects.rb', line 12

def initialize(url:, token:)
  @http = Refocus::Http.new(url: url, token: token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



10
11
12
# File 'lib/refocus/aspects.rb', line 10

def http
  @http
end

Instance Method Details

#allObject



16
17
18
# File 'lib/refocus/aspects.rb', line 16

def all
  json(http.get(""))
end

#create(name:, options: {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/refocus/aspects.rb', line 20

def create(name:, options: {} )
  parent, child = parent_and_name(name)
  path = parent ? "#{parent}/child" : ""
  body =  default_options.merge("name" => child).merge(options)
  json(http.post(path, body: body))
end

#default_optionsObject



39
40
41
42
43
# File 'lib/refocus/aspects.rb', line 39

def default_options
  {
    "timeout" => "5m"
  }
end

#delete(name:) ⇒ Object



31
32
33
# File 'lib/refocus/aspects.rb', line 31

def delete(name:)
  json(http.delete(name))
end

#get(name:) ⇒ Object



35
36
37
# File 'lib/refocus/aspects.rb', line 35

def get(name:)
  json(http.get(name))
end

#update(name:, options: {}) ⇒ Object



27
28
29
# File 'lib/refocus/aspects.rb', line 27

def update(name:, options: {} )
  http.patch(name, body: options)
end