lib/talkie/permission.rb in talkie-0.2.0 vs lib/talkie/permission.rb in talkie-0.3.0
- old
+ new
@@ -1,14 +1,14 @@
# frozen_string_literal: true
module Talkie
class Permission < Struct.new(:user)
- def allow?(action, comment)
+ def allow?(action, comment = Talkie::Comment.new)
action = action.to_s
if user
- return true if action.in? %w[create]
- return true if user.owns_comment?(comment) && action.in?(%w[destroy])
+ return true if action.in? %w[create index]
+ return true if action.in?(%w[destroy]) && user.owns_comment?(comment)
end
false
end
end