lib/dry/schema/messages/yaml.rb in dry-schema-0.2.0 vs lib/dry/schema/messages/yaml.rb in dry-schema-0.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'yaml'
require 'pathname'
require 'dry/equalizer'
require 'dry/schema/messages/abstract'
@@ -14,12 +16,14 @@
attr_reader :data
# @api private
configure do |config|
- config.root = '%{locale}.dry_schema.errors'.freeze
- config.rule_lookup_paths = config.rule_lookup_paths.map { |path| "%{locale}.dry_schema.#{path}" }
+ config.root = '%{locale}.dry_schema.errors'
+ config.rule_lookup_paths = config.rule_lookup_paths.map { |path|
+ "%{locale}.dry_schema.#{path}"
+ }
end
# @api private
def self.build(paths = config.paths)
new(paths.map { |path| load_file(path) }.reduce(:merge))
@@ -30,10 +34,10 @@
flat_hash(YAML.load_file(path))
end
# @api private
def self.flat_hash(h, f = [], g = {})
- return g.update(f.join('.'.freeze) => h) unless h.is_a? Hash
+ return g.update(f.join('.') => h) unless h.is_a? Hash
h.each { |k, r| flat_hash(r, f + [k], g) }
g
end
# @api private