Class: Comet::MongoDBConnection
- Inherits:
-
Object
- Object
- Comet::MongoDBConnection
- Defined in:
- lib/comet/models/mongo_dbconnection.rb
Overview
MongoDBConnection is a typed class wrapper around the underlying Comet Server API data structure.
Instance Attribute Summary collapse
-
#allow_invalid_certificate ⇒ Object
Returns the value of attribute allow_invalid_certificate.
-
#allow_invalid_hostname ⇒ Object
Returns the value of attribute allow_invalid_hostname.
-
#authentication_db ⇒ Object
Returns the value of attribute authentication_db.
-
#client_sslpempath ⇒ Object
Returns the value of attribute client_sslpempath.
-
#mongo_shell_path ⇒ Object
Returns the value of attribute mongo_shell_path.
-
#mongodump_path ⇒ Object
Returns the value of attribute mongodump_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#read_preference ⇒ Object
Returns the value of attribute read_preference.
-
#replica_members ⇒ Object
Returns the value of attribute replica_members.
-
#replica_name ⇒ Object
Returns the value of attribute replica_name.
-
#server ⇒ Object
Returns the value of attribute server.
-
#server_sslpempath ⇒ Object
Returns the value of attribute server_sslpempath.
-
#sshconnection ⇒ Object
Returns the value of attribute sshconnection.
-
#sslclient_key_password ⇒ Object
Returns the value of attribute sslclient_key_password.
-
#unknown_json_fields ⇒ Object
Returns the value of attribute unknown_json_fields.
-
#use_replica ⇒ Object
Returns the value of attribute use_replica.
-
#use_ssh ⇒ Object
Returns the value of attribute use_ssh.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #clear ⇒ Object
- #from_hash(obj) ⇒ Object
- #from_json(json_string) ⇒ Object
-
#initialize ⇒ MongoDBConnection
constructor
A new instance of MongoDBConnection.
-
#to_h ⇒ Hash
The complete object as a Ruby hash.
-
#to_hash ⇒ Hash
The complete object as a Ruby hash.
-
#to_json(options = {}) ⇒ String
The complete object as a JSON string.
Constructor Details
#initialize ⇒ MongoDBConnection
Returns a new instance of MongoDBConnection.
75 76 77 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 75 def initialize clear end |
Instance Attribute Details
#allow_invalid_certificate ⇒ Object
Returns the value of attribute allow_invalid_certificate.
61 62 63 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 61 def allow_invalid_certificate @allow_invalid_certificate end |
#allow_invalid_hostname ⇒ Object
Returns the value of attribute allow_invalid_hostname.
64 65 66 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 64 def allow_invalid_hostname @allow_invalid_hostname end |
#authentication_db ⇒ Object
Returns the value of attribute authentication_db.
28 29 30 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 28 def authentication_db @authentication_db end |
#client_sslpempath ⇒ Object
Returns the value of attribute client_sslpempath.
52 53 54 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 52 def client_sslpempath @client_sslpempath end |
#mongo_shell_path ⇒ Object
Returns the value of attribute mongo_shell_path.
31 32 33 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 31 def mongo_shell_path @mongo_shell_path end |
#mongodump_path ⇒ Object
Returns the value of attribute mongodump_path.
34 35 36 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 34 def mongodump_path @mongodump_path end |
#password ⇒ Object
Returns the value of attribute password.
25 26 27 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 25 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
19 20 21 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 19 def port @port end |
#read_preference ⇒ Object
Returns the value of attribute read_preference.
37 38 39 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 37 def read_preference @read_preference end |
#replica_members ⇒ Object
Returns the value of attribute replica_members.
46 47 48 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 46 def replica_members @replica_members end |
#replica_name ⇒ Object
Returns the value of attribute replica_name.
43 44 45 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 43 def replica_name @replica_name end |
#server ⇒ Object
Returns the value of attribute server.
16 17 18 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 16 def server @server end |
#server_sslpempath ⇒ Object
Returns the value of attribute server_sslpempath.
55 56 57 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 55 def server_sslpempath @server_sslpempath end |
#sshconnection ⇒ Object
Returns the value of attribute sshconnection.
70 71 72 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 70 def sshconnection @sshconnection end |
#sslclient_key_password ⇒ Object
Returns the value of attribute sslclient_key_password.
58 59 60 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 58 def sslclient_key_password @sslclient_key_password end |
#unknown_json_fields ⇒ Object
Returns the value of attribute unknown_json_fields.
73 74 75 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 73 def unknown_json_fields @unknown_json_fields end |
#use_replica ⇒ Object
Returns the value of attribute use_replica.
40 41 42 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 40 def use_replica @use_replica end |
#use_ssh ⇒ Object
Returns the value of attribute use_ssh.
67 68 69 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 67 def use_ssh @use_ssh end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
49 50 51 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 49 def use_ssl @use_ssl end |
#username ⇒ Object
Returns the value of attribute username.
22 23 24 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 22 def username @username end |
Instance Method Details
#clear ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 79 def clear @server = '' @port = 0 @username = '' @password = '' @authentication_db = '' @mongo_shell_path = '' @mongodump_path = '' @read_preference = '' @replica_name = '' @replica_members = [] @client_sslpempath = '' @server_sslpempath = '' @sslclient_key_password = '' @sshconnection = Comet::SSHConnection.new @unknown_json_fields = {} end |
#from_hash(obj) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 105 def from_hash(obj) raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash obj.each do |k, v| case k when 'Server' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @server = v when 'Port' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @port = v when 'Username' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @username = v when 'Password' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @password = v when 'AuthenticationDB' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @authentication_db = v when 'MongoShellPath' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @mongo_shell_path = v when 'MongodumpPath' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @mongodump_path = v when 'ReadPreference' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @read_preference = v when 'UseReplica' @use_replica = v when 'ReplicaName' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @replica_name = v when 'ReplicaMembers' if v.nil? @replica_members = [] else @replica_members = Array.new(v.length) v.each_with_index do |v1, i1| raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String @replica_members[i1] = v1 end end when 'UseSSL' @use_ssl = v when 'ClientSSLPEMPath' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @client_sslpempath = v when 'ServerSSLPEMPath' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @server_sslpempath = v when 'SSLClientKeyPassword' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sslclient_key_password = v when 'AllowInvalidCertificate' @allow_invalid_certificate = v when 'AllowInvalidHostname' @allow_invalid_hostname = v when 'UseSSH' @use_ssh = v when 'SSHConnection' @sshconnection = Comet::SSHConnection.new @sshconnection.from_hash(v) else @unknown_json_fields[k] = v end end end |
#from_json(json_string) ⇒ Object
98 99 100 101 102 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 98 def from_json(json_string) raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String from_hash(JSON.parse(json_string)) end |
#to_h ⇒ Hash
Returns The complete object as a Ruby hash.
219 220 221 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 219 def to_h to_hash end |
#to_hash ⇒ Hash
Returns The complete object as a Ruby hash.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 189 def to_hash ret = {} ret['Server'] = @server ret['Port'] = @port ret['Username'] = @username ret['Password'] = @password ret['AuthenticationDB'] = @authentication_db ret['MongoShellPath'] = @mongo_shell_path ret['MongodumpPath'] = @mongodump_path ret['ReadPreference'] = @read_preference ret['UseReplica'] = @use_replica ret['ReplicaName'] = @replica_name ret['ReplicaMembers'] = @replica_members ret['UseSSL'] = @use_ssl ret['ClientSSLPEMPath'] = @client_sslpempath ret['ServerSSLPEMPath'] = @server_sslpempath ret['SSLClientKeyPassword'] = @sslclient_key_password ret['AllowInvalidCertificate'] = @allow_invalid_certificate ret['AllowInvalidHostname'] = @allow_invalid_hostname ret['UseSSH'] = @use_ssh unless @sshconnection.nil? ret['SSHConnection'] = @sshconnection end @unknown_json_fields.each do |k, v| ret[k] = v end ret end |
#to_json(options = {}) ⇒ String
Returns The complete object as a JSON string.
224 225 226 |
# File 'lib/comet/models/mongo_dbconnection.rb', line 224 def to_json( = {}) to_hash.to_json() end |