def make_exportable(options={})
        return unless self.table_exists?
        # register the class as exportable
        MakeExportable.exportable_classes[self.name] = self

        # remove any invalid options
        valid_options = [:as, :only, :except, :scopes, :conditions, :order, :include,
                         :group, :having, :limit, :offset, :joins]
        options.slice!(*valid_options)

        # Determine the exportable formats, default to all registered formats
        options[:formats] = MakeExportable.exportable_formats.keys
        if format_options = options.delete(:as)
          options[:formats] = options[:formats] & Array.wrap(format_options).map(&:to_sym)
        end
        # Handle case when :as option was sent, but with no valid formats
        if options[:formats].blank?
          valid_formats = MakeExportable.exportable_formats.keys.map {|f| ":#{f}"}
          raise MakeExportable::FormatNotFound.new("No valid export formats. Use: #{valid_formats.join(', ')}")
        end

        # Determine the exportable columns, default to all columns and then
        # remove columns using the :only and :except options
        options[:columns] = column_names.map(&:to_sym)
        if only_options = options.delete(:only)
          options[:columns] = Array.wrap(only_options).map(&:to_sym)
        end
        if except_options = options.delete(:except)
          options[:columns] = options[:columns] - Array.wrap(except_options).map(&:to_sym)
        end

        options[:scopes] ||= []

        # exportable options will be :formats, :columns, :scopes & find options
        class_attribute :exportable_options
        self.exportable_options = options

        extend MakeExportable::ClassMethods
        include MakeExportable::InstanceMethods

      end
def make_exportable(options={})
        return unless self.table_exists?
        # register the class as exportable
        MakeExportable.exportable_classes[self.name] = self

        # remove any invalid options
        valid_options = [:as, :only, :except, :scopes, :conditions, :order, :include,
                         :group, :having, :limit, :offset, :joins]
        options.slice!(*valid_options)

        # Determine the exportable formats, default to all registered formats
        options[:formats] = MakeExportable.exportable_formats.keys
        if format_options = options.delete(:as)
          options[:formats] = options[:formats] & Array.wrap(format_options).map(&:to_sym)
        end
        # Handle case when :as option was sent, but with no valid formats
        if options[:formats].blank?
          valid_formats = MakeExportable.exportable_formats.keys.map {|f| ":#{f}"}
          raise MakeExportable::FormatNotFound.new("No valid export formats. Use: #{valid_formats.join(', ')}")
        end

        # Determine the exportable columns, default to all columns and then
        # remove columns using the :only and :except options
        options[:columns] = column_names.map(&:to_sym)
        if only_options = options.delete(:only)
          options[:columns] = Array.wrap(only_options).map(&:to_sym)
        end
        if except_options = options.delete(:except)
          options[:columns] = options[:columns] - Array.wrap(except_options).map(&:to_sym)
        end

        options[:scopes] ||= []

        # exportable options will be :formats, :columns, :scopes & find options
        class_attribute :exportable_options
        self.exportable_options = options

        extend MakeExportable::ClassMethods
        include MakeExportable::InstanceMethods

      end
<tt>make_exportable</tt> is an ActiveRecord method that, when called, add
 methods to a particular class to make exporting data from that class easier.

 Example:

   class Customer < ActiveRecord::Base
     make_exportable
   end
   Customer.to_export(:csv)

 An optional hash of options can be passed as an argument to establish the default
 export parameters.

 These options include:
 * :only and :except - specify columns or methods to export (defaults to all columns)
 * :as - specify formats to allow for exporting (defaults to all formats)
 * :scopes - specify scopes to be called on the class before exporting
 * find options - for Rails 2.3 and earlier compatibility, standard find options
     are supported (:conditions, :order, :limit, :offset, etc.). These will be deprecated
     and removed in future versions.

 Examples:

   class Customer < ActiveRecord::Base
     make_exportable :only => [:id, :username, :full_name]
   end

   class Customer < ActiveRecord::Base
     make_exportable :except => [:id, :password], :scopes => [:new_signups, :with_referals],
                     :as => [:csv, :tsv, :xls]
   end

   class Customer < ActiveRecord::Base
     make_exportable :conditions => {:active => true}, :order => 'last_name ASC, first_name ASC',
                     :as => [:json, :html, :xml]
   end