Class: DbUrlHelper::Credentials::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/db_url_helper/credentials/generic.rb

Direct Known Subclasses

Credentialias, Environment, Null

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, filters: []) ⇒ Generic

Returns a new instance of Generic.



13
14
15
16
# File 'lib/db_url_helper/credentials/generic.rb', line 13

def initialize service, filters:[]
  @service = service
  @filters = filters
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



12
13
14
# File 'lib/db_url_helper/credentials/generic.rb', line 12

def service
  @service
end

Class Method Details

.weightObject



8
9
10
# File 'lib/db_url_helper/credentials/generic.rb', line 8

def self.weight
  self::WEIGHT
end

Instance Method Details

#credentialObject



33
34
35
# File 'lib/db_url_helper/credentials/generic.rb', line 33

def credential
  OpenStruct.new(user:nil,password:nil)
end

#filtersObject



20
21
22
# File 'lib/db_url_helper/credentials/generic.rb', line 20

def filters
  @filters ||= []
end

#filters=(filters) ⇒ Object



17
18
19
# File 'lib/db_url_helper/credentials/generic.rb', line 17

def filters= filters
  @filters = filters
end

#loadObject



36
37
38
# File 'lib/db_url_helper/credentials/generic.rb', line 36

def load
  Credential.new user,password,weight,self
end

#passwordObject



30
31
32
# File 'lib/db_url_helper/credentials/generic.rb', line 30

def password
  credential.password
end

#userObject



27
28
29
# File 'lib/db_url_helper/credentials/generic.rb', line 27

def user
  credential.user
end

#weightObject



23
24
25
26
# File 'lib/db_url_helper/credentials/generic.rb', line 23

def weight
  return 0 if user.nil? and password.nil?
  self.class::WEIGHT
end