Class: PG::AWS_RDS_IAM::ConnectionInfo::URI
- Inherits:
-
Object
- Object
- PG::AWS_RDS_IAM::ConnectionInfo::URI
- Defined in:
- lib/pg/aws_rds_iam/connection_info/uri.rb
Instance Attribute Summary collapse
-
#auth_token_generator_name ⇒ Object
readonly
Returns the value of attribute auth_token_generator_name.
Class Method Summary collapse
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(connection_string) ⇒ URI
constructor
A new instance of URI.
- #password=(value) ⇒ Object
- #port ⇒ Object
- #to_s ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(connection_string) ⇒ URI
Returns a new instance of URI.
13 14 15 16 17 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 13 def initialize(connection_string) @uri = ::URI.parse(connection_string) @query = @uri.query ? ::URI.decode_www_form(@uri.query).to_h : {} @auth_token_generator_name = @query.delete("aws_rds_iam_auth_token_generator") end |
Instance Attribute Details
#auth_token_generator_name ⇒ Object (readonly)
Returns the value of attribute auth_token_generator_name.
11 12 13 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 11 def auth_token_generator_name @auth_token_generator_name end |
Class Method Details
.match?(connection_string) ⇒ Boolean
7 8 9 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 7 def self.match?(connection_string) /\A#{::URI::RFC2396_PARSER.regexp[:ABS_URI_REF]}\z/.match?(connection_string) end |
Instance Method Details
#host ⇒ Object
23 24 25 26 27 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 23 def host return @query["host"] if @uri.host.nil? || @uri.host.empty? @uri.host end |
#password=(value) ⇒ Object
33 34 35 36 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 33 def password=(value) @uri.password = nil @query["password"] = value end |
#port ⇒ Object
29 30 31 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 29 def port @uri.port || @query["port"] end |
#to_s ⇒ Object
38 39 40 41 42 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 38 def to_s @uri.query = ::URI.encode_www_form(@query) @uri.to_s.sub(%r{^#{@uri.scheme}:(?!//)}, "#{@uri.scheme}://") end |
#user ⇒ Object
19 20 21 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 19 def user @uri.user || @query["user"] end |