Module: I18n::Tasks::Data::Adapter::YamlAdapter

Defined in:
lib/i18n/tasks/data/adapter/yaml_adapter.rb

Class Method Summary collapse

Class Method Details

.dump(tree, options) ⇒ String

Returns:

  • (String)


20
21
22
# File 'lib/i18n/tasks/data/adapter/yaml_adapter.rb', line 20

def dump(tree, options)
  tree.to_yaml(options || {})
end

.parse(str, options) ⇒ Hash

Returns locale tree.

Returns:

  • (Hash)

    locale tree



10
11
12
13
14
15
16
17
# File 'lib/i18n/tasks/data/adapter/yaml_adapter.rb', line 10

def parse(str, options)
  if YAML.method(:load).arity.abs == 2
    YAML.safe_load(str, **(options || {}), permitted_classes: [Symbol], aliases: true)
  else
    # older jruby and rbx 2.2.7 do not accept options
    YAML.load(str)
  end
end