Class: PostgresPR::Authentication
- Inherits:
-
Message
- Object
- Utils::ReadBuffer
- Message
- PostgresPR::Authentication
show all
- Defined in:
- lib/postgres-pr/message.rb
Constant Summary
collapse
- AuthTypeMap =
Hash.new { UnknownAuthType }
Constants inherited
from Message
Message::MsgTypeMap
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Message
#buffer, dump, fields, read, register_message_type
Class Method Details
.create(buffer) ⇒ Object
117
118
119
120
121
122
123
124
|
# File 'lib/postgres-pr/message.rb', line 117
def self.create(buffer)
authtype = buffer.get_int32_network(5)
klass = AuthTypeMap[authtype]
obj = klass.allocate
obj.init_buffer buffer
obj.parse(obj)
obj
end
|
.register_auth_type(type) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/postgres-pr/message.rb', line 126
def self.register_auth_type(type)
raise(PGError, "duplicate auth type registration") if AuthTypeMap.has_key?(type)
AuthTypeMap[type] = self
self.const_set(:AuthType, type)
class_eval "def auth_type() AuthType end"
end
|
Instance Method Details
#dump ⇒ Object
136
137
138
139
140
|
# File 'lib/postgres-pr/message.rb', line 136
def dump
super(4) do |buffer|
buffer.write_int32_network(self.auth_type)
end
end
|
#message__dump ⇒ Object
the dump method of class Message
134
|
# File 'lib/postgres-pr/message.rb', line 134
alias message__dump dump
|
#parse(buffer) ⇒ Object
142
143
144
145
146
147
148
|
# File 'lib/postgres-pr/message.rb', line 142
def parse(buffer)
super do
auth_t = buffer.read_int32_network
raise ParseError unless auth_t == self.auth_type
yield if block_given?
end
end
|