Class: Mongoid::Report::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/report/output.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collection_nameObject

Returns the value of attribute collection_name.



5
6
7
# File 'lib/mongoid/report/output.rb', line 5

def collection_name
  @collection_name
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/mongoid/report/output.rb', line 5

def options
  @options
end

Instance Method Details

#do(rows) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/mongoid/report/output.rb', line 7

def do(rows)
  drop()

  return if rows.empty?

  collection.insert(rows)
end

#dropObject



19
20
21
22
23
24
25
# File 'lib/mongoid/report/output.rb', line 19

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

#present?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mongoid/report/output.rb', line 15

def present?
  collection_name.present?
end