lib/souls/generate/policy.rb in souls-0.21.0 vs lib/souls/generate/policy.rb in souls-0.21.1
- old
+ new
@@ -4,26 +4,27 @@
## Generate Policy
def policy class_name: "souls"
dir_name = "./app/policies"
FileUtils.mkdir_p dir_name unless Dir.exist? dir_name
file_path = "#{dir_name}/#{class_name.singularize}_policy.rb"
+ return "Policy already exist! #{file_path}" if File.exist? file_path
File.open(file_path, "w") do |f|
f.write <<~EOS
class #{class_name.camelize}Policy < ApplicationPolicy
def show?
- admin_permissions?
+ true
end
def index?
- admin_permissions?
+ true
end
def create?
- admin_permissions?
+ staff_permissions?
end
def update?
- admin_permissions?
+ staff_permissions?
end
def delete?
admin_permissions?
end