Class: Superhosting::Controller::Model
- Inherits:
-
Base
- Object
- Base
- Base
- Superhosting::Controller::Model
show all
- Defined in:
- lib/superhosting/controller/model.rb
Instance Attribute Summary
Attributes inherited from Base
#config, #lib
Instance Method Summary
collapse
Methods inherited from Base
#repair
Methods inherited from Base
#get_base_controller_options, #get_controller
Methods included from Helpers
#instance_variables_to_hash
#_config, #_config_options, #_save_registry!, #apply, #configure, #configure_with_apply, #reconfig, #unapply, #unconfigure, #unconfigure_with_unapply
#_command, #_command_without_debug, #command, #command!
#chmod!, #chown!, #chown_r!, #safe_link!, #safe_unlink!
#__debug, #__dry_run, #__dry_run=, #__logger, #__logger=, #debug, #debug_block, #debug_operation, #indent, #indent=, #indent_reset, #indent_step, #indent_step_back, #info, #storage, #t, #with_dry_run, #with_indent, #with_logger
Constructor Details
#initialize(**kwargs) ⇒ Model
Returns a new instance of Model.
4
5
6
7
|
# File 'lib/superhosting/controller/model.rb', line 4
def initialize(**kwargs)
super
@container_controller = self.get_controller(Container)
end
|
Instance Method Details
#_list ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/superhosting/controller/model.rb', line 13
def _list
models = []
@config.models.grep_dirs.each do |model_mapper|
models << model_mapper.name unless model_mapper.abstract?
end
models
end
|
#existing_validation(name:) ⇒ Object
46
47
48
|
# File 'lib/superhosting/controller/model.rb', line 46
def existing_validation(name:)
self._list.include?(name) ? {} : { error: :logical_error, code: :model_does_not_exists, data: { name: name } }
end
|
#index ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/superhosting/controller/model.rb', line 50
def index
index = {}
@container_controller._list.each do |container_name, data|
container_mapper = @container_controller.index[container_name][:mapper]
model = container_mapper.f('model', default: @config.default_model).value
(index[model] ||= []) << container_name
end
index
end
|
#list ⇒ Object
9
10
11
|
# File 'lib/superhosting/controller/model.rb', line 9
def list
{ data: self._list }
end
|
29
30
31
32
33
34
35
36
|
# File 'lib/superhosting/controller/model.rb', line 29
def reconfigure(name:)
if (resp = self.useable_validation(name: name)).net_status_ok?
self.index[name].each do |container_name|
break unless (resp = @container_controller.reconfigure(name: container_name)).net_status_ok?
end
end
resp
end
|
#tree(name:) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/superhosting/controller/model.rb', line 21
def tree(name:)
if (resp = self.existing_validation(name: name)).net_status_ok?
{ data: MapperInheritance::Model.new(@config.models.f(name)).collect_inheritors_tree }
else
resp
end
end
|
#update(name:) ⇒ Object
38
39
40
|
# File 'lib/superhosting/controller/model.rb', line 38
def update(name:)
end
|
#useable_validation(name:) ⇒ Object
42
43
44
|
# File 'lib/superhosting/controller/model.rb', line 42
def useable_validation(name:)
self.index.include?(name) ? {} : { error: :logical_error, code: :model_does_not_used, data: { name: name } }
end
|