Class: RemoteDatabaseCleaner::Config
- Inherits:
-
Object
- Object
- RemoteDatabaseCleaner::Config
- Defined in:
- lib/remote_database_cleaner/config.rb
Constant Summary collapse
- DEFAULT_HOME_CONFIG =
{ :host => nil, :port => nil, :end_point => '/remote_database_cleaner/home/clean' }
Class Method Summary collapse
Instance Method Summary collapse
- #has_home? ⇒ Boolean
- #home_url ⇒ Object
-
#initialize(attrs = {}) ⇒ Config
constructor
A new instance of Config.
- #raise_no_host_error ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Config
Returns a new instance of Config.
18 19 20 21 |
# File 'lib/remote_database_cleaner/config.rb', line 18 def initialize(attrs = {}) attrs[:home] = update_home_config(attrs) super(attrs) end |
Class Method Details
.configure(configs) ⇒ Object
14 15 16 |
# File 'lib/remote_database_cleaner/config.rb', line 14 def self.configure(configs) new(configs) end |
Instance Method Details
#has_home? ⇒ Boolean
42 43 44 |
# File 'lib/remote_database_cleaner/config.rb', line 42 def has_home? !home[:host].nil? && !(home[:host] == '') && !home[:end_point].nil? && !(home[:end_point] == '') end |
#home_url ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/remote_database_cleaner/config.rb', line 23 def home_url raise_no_host_error http = 'http://' if home[:port] "#{ http }#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }" else "#{ http }#{ home.fetch(:host) }#{ home.fetch(:end_point) }" end end |
#raise_no_host_error ⇒ Object
38 39 40 |
# File 'lib/remote_database_cleaner/config.rb', line 38 def raise_no_host_error raise RemoteDatabaseCleanerConfigError.new("RemoteDatabaseCleaner.config.home[:host] can not be nil") unless has_home? end |
#to_hash ⇒ Object
33 34 35 36 |
# File 'lib/remote_database_cleaner/config.rb', line 33 def to_hash raise_no_host_error super.merge(home_url: home_url) end |