Skip to content

Commit

Permalink
fix: hash arguments for unify signatures and cop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsalahutdinov committed Dec 19, 2017
1 parent b86c601 commit 06fd233
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/anyway/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def config_name(val = nil)
#
# my_config = Anyway::Config.for(:my_app)
# # will load data from config/my_app.yml, secrets.my_app, ENV["MY_APP_*"]
def for(explicit_values: {}, name: name)
def for(explicit_values: {}, name: nil)
new(explicit_values: explicit_values, name: name, load: false).load_from_sources
end
end
Expand All @@ -53,12 +53,12 @@ def for(explicit_values: {}, name: name)
def initialize(explicit_values: {}, name: nil, load: true)
@config_name = name || self.class.config_name
raise ArgumentError, "Config name is missing" unless @config_name
reload(explicit_values) if load
load(explicit_values: explicit_values) if load
end

def reload(explicit_values = nil)
def reload(explicit_values: {})
clear
load(explicit_values)
load(explicit_values: explicit_values)
self
end

Expand All @@ -69,7 +69,7 @@ def clear
self
end

def load(explicit_values = nil)
def load(explicit_values: {})
config = load_from_sources((self.class.defaults || {}).deep_dup)

config.merge!(explicit_values) unless explicit_values.nil?
Expand Down
6 changes: 3 additions & 3 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
end

it "sets overrides after loading YAML" do
config = CoolConfig.new(explicit_values: {host: 'overrided.host'})
config = CoolConfig.new(explicit_values: { host: 'overrided.host' })
expect(config.host).to eq "overrided.host"
end

Expand Down Expand Up @@ -90,7 +90,7 @@

config = CoolConfig.new(
explicit_values: {
user: {password: 'explicit_password'}
user: { password: 'explicit_password' }
}
)
expect(config.user[:password]).to eq "explicit_password"
Expand Down Expand Up @@ -148,7 +148,7 @@
end

context "config with initial hash values" do
let(:conf) { SmallConfig.new(explicit_values: {'meta': 'dummy' }) }
let(:conf) { SmallConfig.new(explicit_values: { 'meta': 'dummy' }) }

it "works" do
expect(conf.meta).to eq 'dummy'
Expand Down

0 comments on commit 06fd233

Please sign in to comment.