Sha256: b96b619539bafccd0f76eaeaf757de9989c38f20fac11d5e9d20318b12ca5eb1

Contents?: true

Size: 652 Bytes

Versions: 11

Compression:

Stored size: 652 Bytes

Contents

class BookmarkPolicy < ApplicationPolicy
  def index?
    user.try(:has_role?, 'User')
  end

  def show?
    case user.try(:role).try(:name)
    when 'Administrator'
      true
    when 'Librarian'
      true
    when 'User'
      if record.user == user
        true
      elsif user.profile.try(:share_bookmarks)
        true
      else
        false
      end
    end
  end

  def create?
    user.try(:has_role?, 'User')
  end

  def update?
    case user.try(:role).try(:name)
    when 'Administrator'
      true
    when 'Librarian'
      true
    when 'User'
      true if record.user == user
    end
  end

  def destroy?
    update?
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
enju_bookmark-0.3.2 app/policies/bookmark_policy.rb
enju_bookmark-0.3.1 app/policies/bookmark_policy.rb
enju_bookmark-0.3.0 app/policies/bookmark_policy.rb
enju_bookmark-0.3.0.beta.1 app/policies/bookmark_policy.rb
enju_bookmark-0.2.2 app/policies/bookmark_policy.rb
enju_bookmark-0.2.1 app/policies/bookmark_policy.rb
enju_bookmark-0.2.0 app/policies/bookmark_policy.rb
enju_bookmark-0.2.0.beta.5 app/policies/bookmark_policy.rb
enju_bookmark-0.2.0.beta.3 app/policies/bookmark_policy.rb
enju_bookmark-0.2.0.beta.2 app/policies/bookmark_policy.rb
enju_bookmark-0.2.0.beta.1 app/policies/bookmark_policy.rb