Sha256: f15387da1af4c00bc2200d1c7306c9bb624e1b4e69017016b7e229db9a494a26

Contents?: true

Size: 805 Bytes

Versions: 16

Compression:

Stored size: 805 Bytes

Contents

class Ability
  include CanCan::Ability

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

    can :manage, Query, Query.with_role(user.role) do |query|
      query.roles.include?(user.role)
    end

    can :manage, Alert, Alert.with_role(user.role) do |alert|
      alert.query.roles.include?(user.role)
    end

    can :manage, QueryVersion, QueryVersion.with_role(user.role) do |query_version|
      query_version.query.roles.include?(user.role)
    end

    can :manage, Result, Result.with_role(user.role) do |result|
      if result.query
        result.query.roles.include?(user.role)
      else
        user == result.owner
      end
    end

    can :manage, Visualization, Visualization.with_role(user.role) do |visualization|
      visualization.query.roles.include?(user.role)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev app/models/ability.rb
aleph_analytics-0.4.8 app/models/ability.rb
aleph_analytics-0.4.7 app/models/ability.rb
aleph_analytics-0.4.4 app/models/ability.rb
aleph_analytics-0.4.2 app/models/ability.rb
aleph_analytics-0.4.1 app/models/ability.rb
aleph_analytics-0.3.0 app/models/ability.rb
aleph_analytics-0.2.0 app/models/ability.rb
aleph_analytics-0.1.0 app/models/ability.rb
aleph_analytics-0.0.6 app/models/ability.rb
aleph_analytics-0.0.5 app/models/ability.rb
aleph_analytics-0.0.4 app/models/ability.rb
aleph_analytics-0.0.3 app/models/ability.rb
aleph_analytics-0.0.2 app/models/ability.rb
aleph_analytics-0.0.1.alpha app/models/ability.rb
aleph_analytics-0.0.0.alpha app/models/ability.rb