Sha256: 10ed57241efb39e26acfb97311a44e75ea0a6c2b480dd327c84c45c45664d91f

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

module SafeYAML
  class Transform
    TRANSFORMERS = [
      Transform::ToSymbol.new,
      Transform::ToInteger.new,
      Transform::ToFloat.new,
      Transform::ToNil.new,
      Transform::ToBoolean.new,
      Transform::ToDate.new,
      Transform::ToTime.new
    ]

    def self.to_proper_type(value, quoted=false)
      return value if quoted

      if value.is_a?(String)
        TRANSFORMERS.each do |transformer|
          success, transformed_value = transformer.transform?(value)
          return transformed_value if success
        end
      end

      value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
safe_yaml-0.6.3 lib/safe_yaml/transform.rb
safe_yaml-0.6.2 lib/safe_yaml/transform.rb
safe_yaml-0.6.1 lib/safe_yaml/transform.rb