lib/core/facets/symbol/variablize.rb in facets-2.8.4 vs lib/core/facets/symbol/variablize.rb in facets-2.9.0.pre.1
- old
+ new
@@ -1,12 +1,14 @@
class Symbol
- # Prepend an "@" to the beginning of a symbol
- # to make a instance variable name. This also replaces
- # non-valid characters with underscores.
-
+ # Prepend an "@" to the beginning of a symbol to make a instance
+ # variable name. This also replaces non-valid characters with underscores.
+ #
+ # :a.variablize #=> :"@a"
+ #
def variablize
- "@#{self}".gsub(/\W/, '_').to_sym
+ name = to_s.gsub(/\W/, '_')
+ "@#{name}".to_sym
end
end