class Phlex::SGML
def __nested_attributes__(attributes, base_name, buffer = +"")
- Api: - private
def __nested_attributes__(attributes, base_name, buffer = +"") attributes.each do |k, v| next unless v name = case k when String then k when Symbol then k.name.tr("_", "-") else raise Phlex::ArgumentError.new("Attribute keys should be Strings or Symbols") end case v when true buffer << " " << base_name << name when String buffer << " " << base_name << name << '="' << v.gsub('"', """) << '"' when Symbol buffer << " " << base_name << name << '="' << v.name.tr("_", "-").gsub('"', """) << '"' when Integer, Float buffer << " " << base_name << name << '="' << v.to_s << '"' when Hash __nested_attributes__(v, "#{base_name}#{name}-", buffer) when Array buffer << " " << base_name << name << '="' << __nested_tokens__(v) << '"' when Set buffer << " " << base_name << name << '="' << __nested_tokens__(v.to_a) << '"' else value = if v.respond_to?(:to_phlex_attribute_value) v.to_phlex_attribute_value elsif v.respond_to?(:to_str) v.to_str else v.to_s end buffer << " " << base_name << name << '="' << value.gsub('"', """) << '"' end buffer end end