lib/csv_rails.rb in csv_rails-0.5.2 vs lib/csv_rails.rb in csv_rails-0.6.0
- old
+ new
@@ -1,9 +1,18 @@
require 'csv_rails/array'
-require 'csv_rails/active_record'
+require 'csv_rails/active_model'
-ActiveRecord::Base.send(:include, CsvRails::ActiveRecord)
Array.send(:include, CsvRails::Array)
+
+if defined?(ActiveRecord)
+ require 'csv_rails/active_record'
+ ActiveRecord::Base.send(:include, CsvRails::ActiveRecord)
+end
+
+if defined?(Mongoid)
+ require 'csv_rails/mongoid'
+ Mongoid::Document.send(:include, CsvRails::Mongoid)
+end
ActionController::Renderers.add :csv do |obj, options|
filename = options[:filename] || File.basename(request.path)
send_data obj.to_csv(options), :type => Mime::CSV,
:disposition => "attachment; filename=#{filename}.csv"