2014-07-05 12:59:42 +00:00
|
|
|
class ApplicationPolicy
|
|
|
|
|
2015-05-15 19:13:37 +00:00
|
|
|
class Scope
|
|
|
|
attr_reader :user, :scope
|
|
|
|
|
|
|
|
def initialize(user, scope)
|
|
|
|
@user = user || User.new
|
|
|
|
@scope = scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-05 12:59:42 +00:00
|
|
|
attr_reader :user, :record
|
|
|
|
|
|
|
|
def initialize(user, record)
|
2015-05-08 10:19:52 +00:00
|
|
|
@user = user || User.new
|
2014-07-05 12:59:42 +00:00
|
|
|
@record = record
|
|
|
|
end
|
|
|
|
|
|
|
|
def index?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
|
|
|
scope.where(:id => record.id).exists?
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def new?
|
|
|
|
create?
|
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit?
|
|
|
|
update?
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def scope
|
|
|
|
Pundit.policy_scope!(user, record.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|