Sha256: e1286c97c7ba7419792865dfd18c1d61115e76a871af8dcdaffcb786dd418bd6

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

module Mongoid
  module Report

    class Output
      attr_accessor :collection_name, :options

      def do(rows)
        drop()

        return if rows.empty?

        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

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-report-0.2.2 lib/mongoid/report/output.rb