Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/pez/base.rb
Instance Method Summary collapse
-
#to_yaml(opts = {}) ⇒ Object
Replacing the to_yaml function so it’ll serialize hashes sorted (by their keys) Original from: snippets.dzone.com/posts/show/5811.
Instance Method Details
#to_yaml(opts = {}) ⇒ Object
Replacing the to_yaml function so it’ll serialize hashes sorted (by their keys) Original from: snippets.dzone.com/posts/show/5811
213 214 215 216 217 218 219 220 221 |
# File 'lib/pez/base.rb', line 213 def to_yaml( opts = {} ) YAML::quick_emit( object_id, opts ) do |out| out.map( taguri, to_yaml_style ) do |map| sort.each do |k, v| map.add( k, v ) end end end end |