Class: WebbyNode::Webby
- Defined in:
- lib/webbynode-api/data.rb
Overview
Represents an individual webby with status, reboot/shutdown/start functionality via method_missing
Instance Attribute Summary collapse
Attributes inherited from APIObject
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Webby
constructor
Fetches an individual Webby’s data.
-
#method_missing(method) ⇒ Object
Provides status, start/shutdown/reboot functionality for an individual Webby.
Methods inherited from APIObject
#auth_get, #auth_post, auth_post
Constructor Details
#initialize(options = {}) ⇒ Webby
Fetches an individual Webby’s data.
39 40 41 42 43 |
# File 'lib/webbynode-api/data.rb', line 39 def initialize( = {}) raise ArgumentError, ":hostname is a required argument" unless [:hostname] super() @hostname = [:hostname] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Provides status, start/shutdown/reboot functionality for an individual Webby.
47 48 49 50 51 52 53 54 55 |
# File 'lib/webbynode-api/data.rb', line 47 def method_missing(method) if method.to_s == "status" return auth_get("/api/xml/webby/#{@hostname}/status")["hash"]["status"] elsif %w(start shutdown reboot).include? method.to_s return auth_get("/api/xml/webby/#{@hostname}/#{method.to_s}")["hash"]["job_id"] else raise ArgumentError, "No such action possible on a Webby." end end |
Instance Attribute Details
#hostname ⇒ Object
28 29 30 |
# File 'lib/webbynode-api/data.rb', line 28 def hostname @hostname end |