Class: ROM::CSV::Commands::Delete

Inherits:
ROM::Commands::Delete
  • Object
show all
Defined in:
lib/rom/csv/commands/delete.rb

Instance Method Summary collapse

Instance Method Details

#datasetObject



22
23
24
# File 'lib/rom/csv/commands/delete.rb', line 22

def dataset
  relation.dataset
end

#executeObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rom/csv/commands/delete.rb', line 10

def execute
  original_data = original_dataset.to_a

  dataset.each do |dataset_tuple|
    index = original_data.index(dataset_tuple)
    original_dataset.data.delete(index)
  end

  original_dataset.sync!
  dataset.data
end

#original_datasetObject



26
27
28
# File 'lib/rom/csv/commands/delete.rb', line 26

def original_dataset
  source.dataset
end