Module: R18n::YamlMethods

Included in:
Loader::YAML
Defined in:
lib/r18n-core/yaml_methods.rb

Overview

Base methods to load translations for YAML. It is used by YAML and Rails loaders.

Instance Method Summary collapse

Instance Method Details

#detect_yaml_private_typeObject

Detect class for private type depend on YAML parser.



29
30
31
32
33
34
35
36
37
# File 'lib/r18n-core/yaml_methods.rb', line 29

def detect_yaml_private_type
  @private_type_class = if defined?(JRUBY_VERSION)
    ::YAML::Yecht::PrivateType
  elsif '1.8.' == RUBY_VERSION[0..3]
    ::YAML::PrivateType
  elsif 'syck' == ::YAML::ENGINE.yamler
    ::Syck::PrivateType
  end
end

#initialize_typesObject

Register global types in Psych



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/r18n-core/yaml_methods.rb', line 40

def initialize_types
  if '1.8.' != RUBY_VERSION[0..3] and 'psych' == ::YAML::ENGINE.yamler
    Filters.by_type.keys.each do |type|
      next unless type.is_a? String
      # Yeah, I add R18n’s types to global, send me patch if you really
      # use YAML types too ;).
      Psych.add_domain_type('yaml.org,2002', type) do |full_type, value|
        Typed.new(type, value)
      end
    end
  end
end