class RemoteDatabaseCleaner::Config

Constants

DEFAULT_END_POINT

Attributes

home[RW]
https[RW]

Public Class Methods

new() click to toggle source
# File lib/remote_database_cleaner/config.rb, line 10
def initialize
  @home = default_home_config
  @https = false
end

Public Instance Methods

has_home?() click to toggle source
# 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_url() click to toggle source
# 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_set() click to toggle source
# 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_hash() click to toggle source
# File lib/remote_database_cleaner/config.rb, line 24
def to_hash
  { home:     home,
    home_url: home_url }
end

Private Instance Methods

default_home_config() click to toggle source
# File lib/remote_database_cleaner/config.rb, line 43
def default_home_config
  { :host      => nil,
    :port      => nil,
    :end_point => DEFAULT_END_POINT }
end
hyper_text_transfer_protocal() click to toggle source
# File lib/remote_database_cleaner/config.rb, line 39
def hyper_text_transfer_protocal
  https == true ? 'https' : 'http'
end