class Superhosting::Controller::Model
Public Class Methods
new(**kwargs)
click to toggle source
Calls superclass method
Superhosting::Base::new
# File lib/superhosting/controller/model.rb, line 4 def initialize(**kwargs) super @container_controller = self.get_controller(Container) end
Public Instance Methods
_list()
click to toggle source
# 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:)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/superhosting/controller/model.rb, line 9 def list { data: self._list } end
reconfigure(name:)
click to toggle source
# 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:)
click to toggle source
# 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:)
click to toggle source
# File lib/superhosting/controller/model.rb, line 38 def update(name:) end
useable_validation(name:)
click to toggle source
# 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