The MetaServer class is a helper class created out of the need to store all the Meta-Server related configuration into a single object during the server initialisation.
It holds information about the Meta-Server‘s host name and port number along with credentials to access it.
Objects of this class are never persisted in the DB and only live in memory associated with a user‘s session.
Methods
Attributes
| [R] | host | |
| [W] | host | |
| [W] | password | |
| [R] | password | |
| [R] | port | |
| [W] | port | |
| [W] | user | |
| [R] | user |
Public Class methods
To create a MetaServer object you need to provide a configuration Hash containing the following items:
host port user password
[ show source ]
# File app/models/meta_server.rb, line 21
21: def initialize(attributes={})
22: if (([ 'host', 'port', 'user', 'password' ] & attributes.keys).size != 4)
23: raise 'Submit all the required fields'
24: end
25:
26: @host = attributes.fetch( 'host', '' )
27: @port = attributes.fetch( 'port', '' )
28: @user = attributes.fetch( 'user', '' )
29: @password = attributes.fetch( 'password', '' )
30: end
Public Instance methods
Create an ActiveResource site URL from the configuration settings associated with this MetaServer instance. The format URL will follow this pattern:
http://<user>:<password>@<host>:<port>/
[ show source ]
# File app/models/meta_server.rb, line 37
37: def site_url()
38: return @site_url if defined?(@site_url)
39:
40: @site_url = 'http://'
41: @site_url << @user
42: @site_url << ':'
43: @site_url << @password
44: @site_url << '@'
45: @site_url << @host
46: @site_url << ':'
47: @site_url << @port
48: @site_url << '/'
49:
50: return @site_url
51: end