[ + ]
# File lib/more/facets/snapshot.rb, line 195 def restore_snapshot(snap) replace(snap) end
Converts all keys in the Hash to Strings, returning a new Hash. With a filter parameter, limits conversion to only a certain selection of keys.
foo = { :name=>'Gavin', :wife=>:Lisa } foo.stringify_keys #=> { "name"=>"Gavin", "wife"=>:Lisa } foo.inspect #=> { :name =>"Gavin", :wife=>:Lisa }
This method is considered archaic. Use rekey instead.
[ + ]
# File lib/more/facets/hash/symbolize_keys.rb, line 59 def stringify_keys(&filter) if filter rekey{ |k| filter[k] ? k.to_s : nil } else rekey{ |k| k.to_s } end end
Synonym for Hash#stringify_keys, but modifies the receiver in place and returns it. With a filter parameter, limits conversion to only a certain selection of keys.
foo = { :name=>'Gavin', :wife=>:Lisa } foo.stringify_keys! #=> { "name"=>"Gavin", "wife"=>:Lisa } foo.inspect #=> { "name"=>"Gavin", "wife"=>:Lisa }
This method is considered archaic. Use rekey instead.
[ + ]
# File lib/more/facets/hash/symbolize_keys.rb, line 78 def stringify_keys!(&filter) if filter rekey!{ |k| filter[k] ? k.to_s : nil } else rekey!{ |k| k.to_s } end end
Converts all keys in the Hash to Symbols, returning a new Hash. With a filter, limits conversion to only a certain selection of keys.
foo = { :name=>'Gavin', 'wife'=>:Lisa } foo.symbolize_keys #=> { :name=>"Gavin", :wife=>:Lisa } foo.inspect #=> { "name" =>"Gavin", "wife"=>:Lisa }
This method is considered archaic. Use rekey instead.
[ + ]
# File lib/more/facets/hash/symbolize_keys.rb, line 14 def symbolize_keys(&filter) if filter rekey{ |k| filter[k] ? k.to_sym : nil } else rekey{ |k| k.to_sym } end end
Synonym for Hash#symbolize_keys, but modifies the receiver in place and returns it. With a filter parameter, limits conversion to only a certain selection of keys.
foo = { 'name'=>'Gavin', 'wife'=>:Lisa } foo.symbolize_keys! #=> { :name=>"Gavin", :wife=>:Lisa } foo.inspect #=> { :name=>"Gavin", :wife=>:Lisa }
This method is considered archaic. Use rekey instead.
[ + ]
# File lib/more/facets/hash/symbolize_keys.rb, line 39 def symbolize_keys!(&filter) if filter rekey!{ |k| filter[k] ? k.to_sym : nil } else rekey!{ |k| k.to_sym } end end
[ + ]
# File lib/more/facets/snapshot.rb, line 194 def take_snapshot() dup end
Convert a Hash into an OpenObject.
[ + ]
# File lib/more/facets/openobject.rb, line 241 def to_openobject OpenObject[self] end
[ + ]
# File lib/more/facets/xmlhash.rb, line 67 def to_xml(root='root') Blow::Hash2Xml.convert(root, self) end