Class: SafeYAML::Transform::ToSymbol

Inherits:
Object
  • Object
show all
Defined in:
lib/safe_yaml/transform/to_symbol.rb

Instance Method Summary collapse

Instance Method Details

#transform?(value, options = SafeYAML::OPTIONS) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/safe_yaml/transform/to_symbol.rb', line 4

def transform?(value, options=SafeYAML::OPTIONS)
  if options[:deserialize_symbols] && value =~ /\A:./
    if value =~ /\A:(["'])(.*)\1\Z/
      return true, $2.sub(/^:/, "").to_sym
    else
      return true, value.sub(/^:/, "").to_sym
    end
  end

  return false
end