Class: Hash

Inherits:
Object show all
Defined in:
lib/core_ex/yaml.rb

Instance Method Summary collapse

Instance Method Details

#is_complex_yaml?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/core_ex/yaml.rb', line 185

def is_complex_yaml?
  any? { |x| x.is_complex_yaml? } or inspect.size > 80
end

#old_to_yamlObject



169
# File 'lib/core_ex/yaml.rb', line 169

alias_method :old_to_yaml, :to_yaml

#to_yaml(opts = {}) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
# File 'lib/core_ex/yaml.rb', line 171

def to_yaml ( opts={} )
  inline = nil
  if YAML.have_option? opts, :Inline and not is_complex_yaml?
    inline = :inline
  end
  YAML::quick_emit(object_id, opts) do |out|
    out.map(taguri, to_yaml_style || inline) do |map|
      each { |k, v| map.add k, v }
    end
  end
end