Class: ProjectFifo::Resource
- Inherits:
-
Object
- Object
- ProjectFifo::Resource
show all
- Defined in:
- lib/project-fifo/resource.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(fifo, namespace) ⇒ Resource
Returns a new instance of Resource.
8
9
10
11
|
# File 'lib/project-fifo/resource.rb', line 8
def initialize(fifo, namespace)
@namespace = namespace
@fifo = fifo
end
|
Instance Attribute Details
#fifo ⇒ Object
Returns the value of attribute fifo.
6
7
8
|
# File 'lib/project-fifo/resource.rb', line 6
def fifo
@fifo
end
|
#namespace ⇒ Object
Returns the value of attribute namespace.
6
7
8
|
# File 'lib/project-fifo/resource.rb', line 6
def namespace
@namespace
end
|
Instance Method Details
#[](uuid) ⇒ Object
alias didn’t work. research it
18
19
20
|
# File 'lib/project-fifo/resource.rb', line 18
def [](uuid)
get(uuid)
end
|
#create(data) ⇒ Object
34
35
36
37
|
# File 'lib/project-fifo/resource.rb', line 34
def create(data)
validate!(data)
fifo.post(namespace, data)
end
|
#delete(uuid) ⇒ Object
39
40
41
|
# File 'lib/project-fifo/resource.rb', line 39
def delete(uuid)
fifo.delete(namespace + '/' + uuid)
end
|
#get(uuid) ⇒ Object
22
23
24
|
# File 'lib/project-fifo/resource.rb', line 22
def get(uuid)
fifo.get(namespace + '/' + uuid)
end
|
#get_by_name(name) ⇒ Object
26
27
28
|
# File 'lib/project-fifo/resource.rb', line 26
def get_by_name(name)
list.map{|i| get(i) }.select{|i| i['name'] == name}
end
|
#list ⇒ Object
13
14
15
|
# File 'lib/project-fifo/resource.rb', line 13
def list
fifo.get(namespace)
end
|
30
31
32
|
# File 'lib/project-fifo/resource.rb', line 30
def metadata(uuid, key, value)
fifo.put([ namespace, uuid, 'metadata'].join('/'), { key => value })
end
|
#post(uuid, payload) ⇒ Object
43
44
45
|
# File 'lib/project-fifo/resource.rb', line 43
def post(uuid, payload)
fifo.post(namespace + '/' + uuid, payload)
end
|
#put(uuid, payload) ⇒ Object
47
48
49
|
# File 'lib/project-fifo/resource.rb', line 47
def put(uuid, payload)
fifo.put(namespace + '/' + uuid, payload)
end
|