Module: RailsAssist::Artifact::CRUD::Delete

Defined in:
lib/rails_artifactor/base/crud/delete.rb

Defined Under Namespace

Classes: ViewHelper

Instance Method Summary collapse

Instance Method Details

#remove_artifact(name, *args) ⇒ Object Also known as: delete_artifact



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails_artifactor/base/crud/delete.rb', line 11

def remove_artifact name, *args
  file = ViewHelper.view_file_name(name, args)
  return FileUtils.rm_f(file) if File.exist?(file)

  type = args.first
  type = type[:type] if type.kind_of? Hash
  begin
    file = existing_file_name name, type
    FileUtils.rm_f(file)
    debug "removed artifact: #{name}"
    true
  rescue
    debug "artifact to remove not found: #{name}"
    nil
  end
end

#remove_artifacts(*names) ⇒ Object Also known as: delete_artifacts



29
30
31
32
# File 'lib/rails_artifactor/base/crud/delete.rb', line 29

def remove_artifacts *names
  type = last_option(names)[:type]
  names.flatten.select_labels.each{|name| remove_artifact(name, type) }
end