diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hashie/extensions/parsers/yaml_erb_parser.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/hashie/extensions/parsers/yaml_erb_parser.rb b/lib/hashie/extensions/parsers/yaml_erb_parser.rb index 6a259cb..ed9ae4f 100644 --- a/lib/hashie/extensions/parsers/yaml_erb_parser.rb +++ b/lib/hashie/extensions/parsers/yaml_erb_parser.rb @@ -18,13 +18,30 @@ module Hashie permitted_classes = @options.fetch(:permitted_classes) { [] } permitted_symbols = @options.fetch(:permitted_symbols) { [] } aliases = @options.fetch(:aliases) { true } - # TODO: Psych in newer rubies expects these args to be keyword args. - YAML.safe_load template.result, permitted_classes, permitted_symbols, aliases + + yaml_safe_load(template, permitted_classes, permitted_symbols, aliases) end def self.perform(file_path, options = {}) new(file_path, options).perform end + + private + + if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0') # Ruby 2.6+ + def yaml_safe_load(template, permitted_classes, permitted_symbols, aliases) + YAML.safe_load( + template.result, + permitted_classes: permitted_classes, + permitted_symbols: permitted_symbols, + aliases: aliases + ) + end + else + def yaml_safe_load(template, permitted_classes, permitted_symbols, aliases) + YAML.safe_load(template.result, permitted_classes, permitted_symbols, aliases) + end + end end end end |