Class: RemoteDatabaseCleaner::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_database_cleaner/config.rb

Constant Summary collapse

DEFAULT_END_POINT =
'/remote_database_cleaner/home/clean'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



10
11
12
13
# File 'lib/remote_database_cleaner/config.rb', line 10

def initialize
  @home = default_home_config
  @https = false
end

Instance Attribute Details

#homeObject

Returns the value of attribute home.



8
9
10
# File 'lib/remote_database_cleaner/config.rb', line 8

def home
  @home
end

#httpsObject

Returns the value of attribute https.



8
9
10
# File 'lib/remote_database_cleaner/config.rb', line 8

def https
  @https
end

Instance Method Details

#has_home?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/remote_database_cleaner/config.rb', line 33

def has_home?
  !home[:host].nil? && !(home[:host] == '') && !home[:end_point].nil? && !(home[:end_point] == '')
end

#home_urlObject



15
16
17
18
19
20
21
22
# File 'lib/remote_database_cleaner/config.rb', line 15

def home_url
  raise_if_host_not_set
  if home[:port]
    "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }"
  else
    "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }#{ home.fetch(:end_point) }"
  end
end

#raise_if_host_not_setObject



29
30
31
# File 'lib/remote_database_cleaner/config.rb', line 29

def raise_if_host_not_set
  raise RemoteDatabaseCleanerConfigError.new("RemoteDatabaseCleaner.config.home[:host] can not be nil") unless has_home?
end

#to_hashObject



24
25
26
27
# File 'lib/remote_database_cleaner/config.rb', line 24

def to_hash
  { home:     home,
    home_url: home_url }
end