Class: Weavr::Resource
- Inherits:
-
Object
show all
- Includes:
- Gorillib::Builder
- Defined in:
- lib/weavr/resource.rb
Direct Known Subclasses
Cluster, Collection, Component, Configuration, Host, HostRole, OperatingSystem, Repository, Request, Service, ServiceComponent, Stack, StackConfiguration, StackService, StackVersion, Task
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.child_resources ⇒ Object
25
26
27
|
# File 'lib/weavr/resource.rb', line 25
def child_resources
@resources ||= []
end
|
12
13
14
|
# File 'lib/weavr/resource.rb', line 12
def params
params.merge(params[label] || {})
end
|
.label ⇒ Object
16
17
18
|
# File 'lib/weavr/resource.rb', line 16
def label
name.demodulize.pluralize
end
|
.load_definitions! ⇒ Object
29
30
31
32
33
|
# File 'lib/weavr/resource.rb', line 29
def load_definitions!
child_resources.each do |name|
require File.expand_path("../resource/#{name.underscore}", __FILE__)
end
end
|
.predefine_class(name) ⇒ Object
20
21
22
23
|
# File 'lib/weavr/resource.rb', line 20
def predefine_class name
Weavr.const_set(name, Class.new(self))
child_resources << name
end
|
.receive(params, &blk) ⇒ Object
8
9
10
|
# File 'lib/weavr/resource.rb', line 8
def receive(params, &blk)
super (params, &blk)
end
|
Instance Method Details
#connection ⇒ Object
40
41
42
|
# File 'lib/weavr/resource.rb', line 40
def connection
Weavr.connection
end
|
#receive!(params) ⇒ Object
36
37
38
|
# File 'lib/weavr/resource.rb', line 36
def receive! params
super self.class.(params)
end
|
#refresh! ⇒ Object
48
49
50
51
|
# File 'lib/weavr/resource.rb', line 48
def refresh!
receive! resource_action(:get)
self
end
|
#resource_action(action, data = {}) ⇒ Object
44
45
46
|
# File 'lib/weavr/resource.rb', line 44
def resource_action(action, data = {})
connection.resource(action, href, data)
end
|