Inlining yaml

I want to be able to inline certain parts of yaml output that are
embedded within a structure. Here's the approach I'm taking -- does
it look reasonable? Can anyone recommend a better approach? -dan

require 'yaml'
class Object
  def inline!
    class << self; def to_yaml_style; :inline; end; end
    self
  end
end

ary = %w[a b c]
ary.inline!
other = %w[a b c]

puts ({ 'ary' => ary, 'other' => other }).to_yaml

···

---
ary: [a, b, c]
other:
- a
- b
- c