Sha256: b56579a4df7d386bab58ac718af8752cfbdc5b6dfc3db23d9faf2a3345f49980

Contents?: true

Size: 979 Bytes

Versions: 5

Compression:

Stored size: 979 Bytes

Contents

require 'sugar-high/array'

require 'rails3_artifactor/artifact/file_name/view'

module Rails3::Assist::Artifact::CRUD
  module Delete
    class ViewHelper
      extend Rails3::Assist::Artifact::View::FileName
    end
    
    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
    alias_method :delete_artifact, :remove_artifact

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails3_artifactor-0.4.0 lib/rails3_artifactor/base/crud/delete.rb
rails3_artifactor-0.3.2 lib/rails3_artifactor/base/crud/delete.rb
rails3_artifactor-0.3.1 lib/rails3_artifactor/base/crud/delete.rb
rails3_artifactor-0.3.0 lib/rails3_artifactor/base/crud/delete.rb
rails3_artifactor-0.2.8 lib/rails3_artifactor/base/crud/delete.rb