Class: Superhosting::Controller::Container::Admin
- Defined in:
- lib/superhosting/controller/container/admin.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #_list ⇒ Object
- #_list_users ⇒ Object
- #add(name:) ⇒ Object
- #delete(name:) ⇒ Object
-
#initialize(name:, **kwargs) ⇒ Admin
constructor
A new instance of Admin.
- #list ⇒ Object
Methods inherited from Base
Methods inherited from Base
#get_base_controller_options, #get_controller
Methods included from Helpers
Methods included from Helper::Config
#_config, #_config_options, #_save_registry!, #apply, #configure, #configure_with_apply, #reconfig, #unapply, #unconfigure, #unconfigure_with_unapply
Methods included from Helper::Cmd
#_command, #_command_without_debug, #command, #command!
Methods included from Helper::File
#chmod!, #chown!, #chown_r!, #safe_link!, #safe_unlink!
Methods included from Helper::Logger
#__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(name:, **kwargs) ⇒ Admin
Returns a new instance of Admin.
5 6 7 8 9 10 |
# File 'lib/superhosting/controller/container/admin.rb', line 5 def initialize(name:, **kwargs) super(kwargs) @container_name = name @user_controller = self.get_controller(User) @admin_controller = self.get_controller(Controller::Admin) end |
Instance Method Details
#_list ⇒ Object
17 18 19 20 21 |
# File 'lib/superhosting/controller/container/admin.rb', line 17 def _list self._list_users.map do |user| { admin: user[/(?<=#{@container_name}_admin_)(.*)/], user: user } end end |
#_list_users ⇒ Object
39 40 41 42 |
# File 'lib/superhosting/controller/container/admin.rb', line 39 def _list_users users = @user_controller._group_get_users_names(name: @container_name) users.select {|user| user.start_with? "#{@container_name}_admin_" } end |
#add(name:) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/superhosting/controller/container/admin.rb', line 23 def add(name:) if (resp = @admin_controller.existing_validation(name: name)).net_status_ok? admin_container_controller = self.get_controller(Controller::Admin::Container, name: name) resp = admin_container_controller.add(name: @container_name) end resp end |
#delete(name:) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/superhosting/controller/container/admin.rb', line 31 def delete(name:) if (resp = @admin_controller.existing_validation(name: name)).net_status_ok? admin_container_controller = self.get_controller(Controller::Admin::Container, name: name) resp = admin_container_controller.delete(name: @container_name) end resp end |
#list ⇒ Object
12 13 14 15 |
# File 'lib/superhosting/controller/container/admin.rb', line 12 def list container_admins = self._list { data: container_admins } end |