Sha256: 9b079572c5173adeb5877c870e9512e5b80ecb34b52767e7ad38682bed271e36

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module RailsAssist::Artifact
  RailsAssist.artifacts.each do |name|
    plural_name = name.to_s.pluralize
    class_eval %{
      module #{name.to_s.camelize}
        def remove_#{name} name
          remove_artifact name, :#{name}
        end

        def remove_#{plural_name} *names
          remove_artifacts :#{name}, *names
        end

        def remove_all_#{plural_name}
          RailsAssist::Artifact::Files.#{name}_files.each do |file_name|
            ::File.delete_file! file_name if ::File.file?(file_name)
          end
        end
        alias_method :delete_all_#{plural_name}, :remove_all_#{plural_name}

        def remove_#{plural_name} *names
          return remove_all_#{plural_name} if names.empty?
          names.to_strings.each do |name|
            file_name = #{name}_file(name)
            ::File.delete!(file_name) if file_name && ::File.file?(file_name)
          end
        end
        alias_method :delete_#{plural_name}, :remove_#{plural_name}
        alias_method :remove_#{name}, :remove_#{plural_name}
        alias_method :delete_#{name}, :remove_#{plural_name}
      end
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_artifactor-0.5.1 lib/rails_artifactor/artifact/crud/delete.rb