def attributes(*args, &block)
      options = args.extract_options!
      options[:html] ||= {}

      if args.first and args.first.is_a? String
        options[:name] = args.shift
      end

      if options[:for].blank?
        attributes_for(record, args, options, &block)
      else
        for_value = if options[:for].is_a? Symbol
          record.send(options[:for])
        else
          options[:for]
        end

        [*for_value].map do |value|
          value_options = options.clone
          value_options[:html][:class] = [ options[:html][:class], value.class.to_s.underscore ].compact.join(" ")

          attributes_for(value, args, options, &block)
        end.join.html_safe
      end

    end
def attributes(*args, &block)
      options = args.extract_options!
      options[:html] ||= {}

      if args.first and args.first.is_a? String
        options[:name] = args.shift
      end

      if options[:for].blank?
        attributes_for(record, args, options, &block)
      else
        for_value = if options[:for].is_a? Symbol
          record.send(options[:for])
        else
          options[:for]
        end

        [*for_value].map do |value|
          value_options = options.clone
          value_options[:html][:class] = [ options[:html][:class], value.class.to_s.underscore ].compact.join(" ")

          attributes_for(value, args, options, &block)
        end.join.html_safe
      end

    end
Creates block of attributes with optional header. Attributes are surrounded with ordered list.

 @overload attributes(options = {}, &block)
   Creates attributes list without header, yields block to include each attribute

   @param [Hash] options Options for formating attributes block
   @option options [String] :name (nil) Optional header of attributes section
   @option options [String] :class ('') Name of html class to add to attributes block
   @option options [String] :header_class ('') Name of html class to add to header
   @yield Block which can call #attribute to include attribute value

   @example
     <%= attr.attributes do %>
       <%= attr.attribute :name %>
       <%= attr.attribute :email %>
     <% end %>

   @example
     <%= attr.attributes :name => "User" do %>
       <%= attr.attribute :name %>
       <%= attr.attribute :email %>
     <% end %>

   @example
     <%= attr.attributes :for => :user do |user| %>
       <%= user.attribute :name %>
       <%= user.attribute :email %>
       <%= user.attribute :profile do %>
         <%= link_to h(user.record.name), user_path(user.record) %>
       <% end %>
     <% end %>

   @example
     <%= attr.attributes :for => @user do |user| %>
       <%= user.attribute :name %>
       <%= user.attribute :email %>
       <%= user.attribute :profile do %>
         <%= link_to h(@user.name), user_path(@user) %>
       <% end %>
     <% end %>

   @example
     <%= attr.attributes :for => :posts do |post| %>
       <%= post.attribute :author %>
       <%= post.attribute :title %>
     <% end %>

   @example
     <%= attr.attributes :for => @posts do |post| %>
       <%= post.attribute :author %>
       <%= post.attribute :title %>
     <% end %>

   @example
     <%= attr.attributes :for => @posts do |post| %>
       <%= post.attribute :birthday, :format => false %>
     <% end %>

   @example
     <%= attr.attributes :for => @posts do |post| %>
       <%= post.attribute :birthday, :format => :my_fancy_birthday_formatter %>
     <% end %>

 @overload attributes(header, options = {}, &block)
   Creates attributes list with header and yields block to include each attribute

   @param [String] header Header of attributes section
   @param [Hash] options Options for formating attributes block
   @option options [String] :class ('') Name of html class to add to attributes block
   @option options [String] :header_class ('') Name of html class to add to header
   @option optinos [Symbol,Object] :for Optional new record for new builder
     passed as argument block. This new record can be symbol of method name for actual
     record, or any other object which is passed as new record for builder.
   @yield Block which can call #attribute to include attribute value
   @yieldparam builder Builder instance holding actual record (retivable via #record)

   @example
     <%= attr.attributes "User info" do %>
       <%= attr.attribute :name" %>
       <%= attr.attribute :email %>
     <% end %>

   @example
     <%= attr.attributes "User", :for => :user do |user| %>
       <%= user.attribute :name %>
       <%= user.attribute :email %>
       <%= user.attribute :profile do %>
         <%= link_to h(user.record.name), user_path(user.record) %>
       <%  end %>
     <% end %>

   @example
     <% attr.attributes "User", :for => @user do |user| %>
       <%= user.attribute :name %>
       <%= user.attribute :email %>
       <%= user.attribute :profile do %>
         <%= link_to h(@user.name), user_path(@user) %>
       <% end %>
     <% end %>

   @example
     <%= attr.attributes "Post", :for => :posts do |post| %>
       <%= post.attribute :author %>
       <%= post.attribute :title %>
     <% end %>

   @example
     <%= attr.attributes "Post", :for => @posts do |post| %>
       <%= post.attribute :author %>
       <%= post.attribute :title %>
     <% end %>

 @overload attributes(*symbols, options = {})
   Creates attributes list without header, attributes are given as list of symbols (record properties)

   @param [Symbol, ...] symbols List of attributes
   @param [Hash] options Options for formating attributes block
   @option options [String] :name (nil) Optional header of attributes section
   @option options [String] :class ('') Name of html class to add to attributes block
   @option options [String] :header_class ('') Name of html class to add to header

   @example
     <%= attr.attributes :name, :email %>

   @example
     <%= attr.attributes :name, :email, :for => :author %>

   @example
     <%= attr.attributes :name, :email, :for => @user %>

   @example
     <%= attr.attributes :title, :for => :posts %>

   @example
     <%= attr.attributes :title, :for => @posts %>

 @overload attributes(header, *symbols, options = {})
   Creates attributes list with header, attributes are given as list of symbols (record properties)

   @param [String] header Header of attributes section
   @param [Symbol, ...] symbols Optional list of attributes
   @param [Hash] options Options for formating attributes block
   @option options [String] :class ('') Name of html class to add to attributes block
   @option options [String] :header_class ('') Name of html class to add to header

   @example
     <%= attr.attributes "User info" :name, :email %>

   @example
     <%= attr.attributes "Author", :name, :email, :for => :author %>

   @example
     <%= attr.attributes "Author", :name, :email, :for => @user %>

   @example
     <%= attr.attributes "Post", :title, :for => :posts %>

   @example
     <%= attr.attributes "Post", :title, :for => @posts %>

 @example All together
   <%= attr.attributes "User info", :name, :email, :class => "user_info", :header_class => "header important" %>

 @example With block
   <%= attr.attributes "User info" :class => "user_info", :header_class => "header important" do %>
     <%= attr.attribute :name %>
     <%= attr.attribute :email %>
   <% end %>

 @see #attribute