Class: SearchAction

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/admin_data/search_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation) ⇒ SearchAction

Returns a new instance of SearchAction.



4
5
6
# File 'app/controllers/admin_data/search_controller.rb', line 4

def initialize(relation)
  @relation = relation
end

Instance Attribute Details

#relationObject

Returns the value of attribute relation.



2
3
4
# File 'app/controllers/admin_data/search_controller.rb', line 2

def relation
  @relation
end

#success_messageObject

Returns the value of attribute success_message.



2
3
4
# File 'app/controllers/admin_data/search_controller.rb', line 2

def success_message
  @success_message
end

Instance Method Details

#deleteObject



8
9
10
11
12
# File 'app/controllers/admin_data/search_controller.rb', line 8

def delete
  count = relation.count
  relation.delete_all
  self.success_message = "#{count} #{AdminData::Util.pluralize(count, 'record')} deleted"
end

#destroyObject



14
15
16
17
18
19
20
# File 'app/controllers/admin_data/search_controller.rb', line 14

def destroy
  count = relation.count
  relation.find_in_batches do |group|
    group.each {|record| record.destroy }
  end
  self.success_message = "#{count} #{AdminData::Util.pluralize(count, 'record')} destroyed"
end