Class: Superhosting::Controller::Site::Alias
- Defined in:
- lib/superhosting/controller/site/alias.rb
Instance Method Summary collapse
- #add(name:) ⇒ Object
- #delete(name:) ⇒ Object
-
#initialize(name:, **kvargs) ⇒ Alias
constructor
A new instance of Alias.
Methods inherited from Base
Methods included from Helpers
#create_conf, #erb, #instance_variables_to_hash, #remove_line_from_file, #write_if_not_exist
Constructor Details
#initialize(name:, **kvargs) ⇒ Alias
Returns a new instance of Alias.
5 6 7 8 |
# File 'lib/superhosting/controller/site/alias.rb', line 5 def initialize(name:, **kvargs) raise NetStatus::Exception, { error: :logical_error, message: "Site '#{name}' doesn't exists." } unless @site_descriptor = Site.new(kvargs).site_index[name] super(kvargs) end |
Instance Method Details
#add(name:) ⇒ Object
10 11 12 13 |
# File 'lib/superhosting/controller/site/alias.rb', line 10 def add(name:) return { error: :input_error, message: "Invalid alias name '#{name}' - only '#{Site::DOMAIN_NAME_FORMAT}' are allowed" } if name !~ Site::DOMAIN_NAME_FORMAT write_if_not_exist(@site_descriptor[:site].aliases._path, name) end |
#delete(name:) ⇒ Object
15 16 17 |
# File 'lib/superhosting/controller/site/alias.rb', line 15 def delete(name:) remove_line_from_file(@site_descriptor[:site].aliases._path, name) end |