Class: PictureFilePolicy

Inherits:
ApplicationPolicy
  • Object
show all
Defined in:
app/policies/picture_file_policy.rb

Instance Method Summary collapse

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/policies/picture_file_policy.rb', line 17

def create?
  true if user.try(:has_role?, 'Librarian')
end

#destroy?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/policies/picture_file_policy.rb', line 29

def destroy?
  true if user.try(:has_role?, 'Librarian')
end

#edit?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/policies/picture_file_policy.rb', line 21

def edit?
  true if user.try(:has_role?, 'Librarian')
end

#index?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'app/policies/picture_file_policy.rb', line 2

def index?
  true
end

#show?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
# File 'app/policies/picture_file_policy.rb', line 6

def show?
  case user.try(:role).try(:name)
  when 'Librarian'
    true
  when 'User'
    true if record.picture_attachable.try(:required_role_id).to_i <= 2
  else
    true if record.picture_attachable.try(:required_role_id).to_i <= 1
  end
end

#update?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/policies/picture_file_policy.rb', line 25

def update?
  true if user.try(:has_role?, 'Librarian')
end