160: def yaml_inline= bool
161: if respond_to?("to_yaml_style")
162: self.to_yaml_style = :inline
163: else
164: unless defined? @__yaml_inline_meth
165: @__yaml_inline_meth =
166: lambda {|opts|
167: YAML::quick_emit(object_id, opts) {|emitter|
168: emitter << '{ ' << map{|kv| kv.join ': '}.join(', ') << ' }'
169: }
170: }
171: class << self
172: def to_yaml opts = {}
173: begin
174: @__yaml_inline ? @__yaml_inline_meth[ opts ] : super
175: rescue
176: @to_yaml_style = :inline
177: super
178: end
179: end
180: end
181: end
182: end
183: @__yaml_inline = bool
184: end