Class: RemoteDatabaseCleaner::Config
- Inherits:
-
Object
- Object
- RemoteDatabaseCleaner::Config
- Defined in:
- lib/remote_database_cleaner/config.rb
Constant Summary collapse
- DEFAULT_END_POINT =
'/remote_database_cleaner/home/clean'.freeze
Instance Attribute Summary collapse
-
#home ⇒ Object
Returns the value of attribute home.
-
#https ⇒ Object
Returns the value of attribute https.
Instance Method Summary collapse
- #has_home? ⇒ Boolean
- #home_url ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #raise_if_host_not_set ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Config
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
#home ⇒ Object
Returns the value of attribute home.
8 9 10 |
# File 'lib/remote_database_cleaner/config.rb', line 8 def home @home end |
#https ⇒ Object
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
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_url ⇒ Object
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_set ⇒ Object
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_hash ⇒ Object
24 25 26 27 |
# File 'lib/remote_database_cleaner/config.rb', line 24 def to_hash { home: home, home_url: home_url } end |