Sha256: 72da13e4b03ad3d8b419f41b042219e0ad9314f9375ef29705719a4e45ed92f6

Contents?: true

Size: 800 Bytes

Versions: 16

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

# Ability class for our dummy app. Used by CanCanCan to determine
# the appropriate permissions for current_ability
class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    can :list, WorksCited::Citation
    can :list, WorksCited::Contributor

    return if user.new_record? # Anonymous Users leave

    can :read, WorksCited::Citation
    can :read, WorksCited::Contributor
    # # We could have other rules in here, like:
    # can :manage, WorksCited::Citation, record: { user_id: user.id }
    # can :manage, WorksCited::Contributor, record: { user_id: user.id }

    return unless user.admin? # Non Admin Users leave

    can :select, :all
    can :manage, WorksCited::Citation
    can :manage, WorksCited::Contributor
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
works_cited-0.1.16 spec/dummy/app/models/ability.rb
works_cited-0.1.15 spec/dummy/app/models/ability.rb
works_cited-0.1.14 spec/dummy/app/models/ability.rb
works_cited-0.1.13 spec/dummy/app/models/ability.rb
works_cited-0.1.11 spec/dummy/app/models/ability.rb
works_cited-0.1.10 spec/dummy/app/models/ability.rb
works_cited-0.1.9 spec/dummy/app/models/ability.rb
works_cited-0.1.8 spec/dummy/app/models/ability.rb
works_cited-0.1.7 spec/dummy/app/models/ability.rb
works_cited-0.1.6 spec/dummy/app/models/ability.rb
works_cited-0.1.5 spec/dummy/app/models/ability.rb
works_cited-0.1.4 spec/dummy/app/models/ability.rb
works_cited-0.1.3 spec/dummy/app/models/ability.rb
works_cited-0.1.2 spec/dummy/app/models/ability.rb
works_cited-0.1.1 spec/dummy/app/models/ability.rb
works_cited-0.1.0 spec/dummy/app/models/ability.rb