Class: PleskLib::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/plesk_lib/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, username, password) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
# File 'lib/plesk_lib/server.rb', line 5

def initialize(host, username, password)
  @host = host
  @username = username
  @password = password
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/plesk_lib/server.rb', line 11

def method_missing(method_name, *args)
  begin
    action_class = "PleskLib::Actions::#{method_name.to_s.camelize}".constantize
  rescue NameError => e
    raise NoMethodError, "The Action #{e.name} is not available. Please check the action docs."
  else
    action = action_class.new(*args)
    action.execute_on(self)
    return action
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/plesk_lib/server.rb', line 3

def host
  @host
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/plesk_lib/server.rb', line 3

def password
  @password
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/plesk_lib/server.rb', line 3

def username
  @username
end