Advertisement
mechnicov

Untitled

Jun 12th, 2021
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.65 KB | None | 0 0
  1. class ApplicationPolicy
  2.   attr_reader :context, :record, :cookies, :user
  3.  
  4.   delegate :cookies, to: :context
  5.   delegate :user, to: :context
  6.  
  7.   def initialize(context, record)
  8.     @context = context
  9.     @record = record
  10.   end
  11.  
  12.   def index?
  13.     false
  14.   end
  15.  
  16.   def show?
  17.     false
  18.   end
  19.  
  20.   def create?
  21.     false
  22.   end
  23.  
  24.   def new?
  25.     create?
  26.   end
  27.  
  28.   def update?
  29.     false
  30.   end
  31.  
  32.   def edit?
  33.     update?
  34.   end
  35.  
  36.   def destroy?
  37.     false
  38.   end
  39.  
  40.   class Scope
  41.     attr_reader :user, :scope
  42.  
  43.     def initialize(user, scope)
  44.       @user = user
  45.       @scope = scope
  46.     end
  47.  
  48.     def resolve
  49.       scope.all
  50.     end
  51.   end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement