Class: Avm::Oracle::ConnectionStringBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/oracle/connection_string_builder.rb

Constant Summary collapse

DEFAULT_PORT =
1521
FIELDS =
%w[user password host port service_name].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ ConnectionStringBuilder

Returns a new instance of ConnectionStringBuilder.



13
14
15
16
17
18
19
20
21
# File 'lib/avm/oracle/connection_string_builder.rb', line 13

def initialize(options = nil)
  if options.is_a?(String)
    self.string = options
  elsif options.is_a?(Hash)
    options.each do |k, v|
      send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#stringObject

Returns the value of attribute string.



11
12
13
# File 'lib/avm/oracle/connection_string_builder.rb', line 11

def string
  @string
end

Instance Method Details

#buildObject



27
28
29
30
31
32
33
34
# File 'lib/avm/oracle/connection_string_builder.rb', line 27

def build
  if string
    string
  else
    validate_fields
    "#{user}/#{password}@//#{host}:#{port}/#{service_name}"
  end
end

#portObject



23
24
25
# File 'lib/avm/oracle/connection_string_builder.rb', line 23

def port
  @port || DEFAULT_PORT
end