Skip to content

Commit

Permalink
Fix for ruby < 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
eddloschi committed Mar 18, 2017
1 parent 5001244 commit d368d79
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mongoid/giza/configuration.rb
Expand Up @@ -27,7 +27,7 @@ def initialize
# defined
# @param env [String] environment whoose settings will be loaded
def load(path, env)
YAML.safe_load(File.open(path).read)[env].each do |section, settings|
yaml_safe_load(File.open(path).read)[env].each do |section, settings|
section = instance_variable_get("@#{section}")
next unless section
settings.each do |setting, value|
Expand Down Expand Up @@ -173,6 +173,16 @@ def setter(section, setting, value)
method = "#{setting}="
section.send(method, value) if section.respond_to?(method)
end

private

def yaml_safe_load(yaml_code)
if YAML.respond_to?(:safe_load)
YAML.safe_load(yaml_code)
else
YAML.load(yaml_code) # rubocop:disable Security/YAMLLoad
end
end
end
end
end

0 comments on commit d368d79

Please sign in to comment.