Class: SafeYAML::Transform

### Home Classes Methods

### In Files

- lib/safe_yaml/transform.rb
- lib/safe_yaml/transform/to_boolean.rb
- lib/safe_yaml/transform/to_date.rb
- lib/safe_yaml/transform/to_float.rb
- lib/safe_yaml/transform/to_integer.rb
- lib/safe_yaml/transform/to_nil.rb
- lib/safe_yaml/transform/to_symbol.rb
- lib/safe_yaml/transform/transformation_map.rb

### Parent

Object

### Namespace

- MODULE SafeYAML::Transform::TransformationMap
- CLASS SafeYAML::Transform::ToBoolean
- CLASS SafeYAML::Transform::ToDate
- CLASS SafeYAML::Transform::ToFloat
- CLASS SafeYAML::Transform::ToInteger
- CLASS SafeYAML::Transform::ToNil
- CLASS SafeYAML::Transform::ToSymbol

### Methods

- ::to_guessed_type
- ::to_proper_type

### Class/Module Index

Quicksearch

- SafeYAML
- SafeYAML::Deep
- SafeYAML::Parse
- SafeYAML::Parse::Date
- SafeYAML::Parse::Hexadecimal
- SafeYAML::Parse::Sexagesimal
- SafeYAML::PsychHandler
- SafeYAML::PsychResolver
- SafeYAML::Resolver
- SafeYAML::SafeToRubyVisitor
- SafeYAML::SyckResolver
- SafeYAML::Transform
- SafeYAML::Transform::ToBoolean
- SafeYAML::Transform::ToDate
- SafeYAML::Transform::ToFloat
- SafeYAML::Transform::ToInteger
- SafeYAML::Transform::ToNil
- SafeYAML::Transform::ToSymbol
- SafeYAML::Transform::TransformationMap
- SafeYAML::Transform::TransformationMap::CaseAgnosticMap
- SafeYAML::Transform::TransformationMap::ClassMethods
- Object
- YAML

No matching classes.

# SafeYAML::Transform

### Constants

TRANSFORMERS

### Public Class Methods

to_guessed_type(value, quoted=false, options=nil) click to toggle source

    # File lib/safe_yaml/transform.rb, line 14
    def self.to_guessed_type(value, quoted=false, options=nil)
      return value if quoted

      if value.is_a?(String)
        TRANSFORMERS.each do |transformer|
          success, transformed_value = transformer.method(:transform?).arity == 1 ?
            transformer.transform?(value) :
            transformer.transform?(value, options)

          return transformed_value if success
        end
      end

      value
    end

to_proper_type(value, quoted=false, tag=nil, options=nil) click to toggle source

    # File lib/safe_yaml/transform.rb, line 30
    def self.to_proper_type(value, quoted=false, tag=nil, options=nil)
      case tag
      when "tag:yaml.org,2002:binary", "x-private:binary", "!binary"
        decoded = Base64.decode64(value)
        decoded = decoded.force_encoding(value.encoding) if decoded.respond_to?(:force_encoding)
        decoded
      else
        self.to_guessed_type(value, quoted, options)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.