Sha256: 7c6f97f9aacc3a936967993422ed587807980d15ca151eebccaa7ae8aeef136c

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

Contents

module Mongoid
  module Report

    class Output
      attr_accessor :collection_name, :options

      def do(rows)
        drop()
        collection.insert(rows)
      end

      def present?
        collection_name.present?
      end

      def drop
        return collection.drop() unless options[:drop].present?

        # We will use custom way for dropping the collection or removing the
        # records partially
        collection.find(options[:drop]).remove_all()
      end

      private

      def collection
        @collection ||= Collections.get(collection_name)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-report-0.2.1 lib/mongoid/report/output.rb
mongoid-report-0.2.0 lib/mongoid/report/output.rb