Sha256: edb1afbf2f9fc5e26b7ae650c0e5ec3437c3bc514513502c851d9486e008224d

Contents?: true

Size: 1.04 KB

Versions: 63

Compression:

Stored size: 1.04 KB

Contents

class Ability
  include CanCan::Ability

  def initialize(usuario)
    usuario ||= Usuario.new

    alias_action :index, :show, :query, :to => :read
    alias_action :new, :to => :create
    alias_action :edit, :to => :update
    alias_action :action, :to => :create_or_update
    # alias_action :destroy_selected, :to => :destroy

    if usuario.root?
      can :manage, :all
      # can :read, Teste
    else
      #Permissão global
      # can :manage, Dashboard

      # #Permissão fixa
      # case usuario.papel.chave
      #   when "admin"
      # end

      #Permissão dinamica
      if usuario.perfil
        usuario.perfil.permissoes.each do |permissao|
          # if usuario.reference_id.present? && permissao.klass.constantize.attribute_method?(:reference_id)
            can permissao.abilities, permissao.klass.constantize, reference_id: usuario.reference_id
          # else
            # can permissao.abilities, permissao.klass.constantize
          # end
        end
      end
    end
    #Condições especificas de autorização
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
templus_models-1.6.6 test/dummy/app/models/ability.rb
templus_models-2.0.6 test/dummy/app/models/ability.rb
templus_models-2.0.5 test/dummy/app/models/ability.rb
templus_models-2.0.4 test/dummy/app/models/ability.rb
templus_models-2.0.3 test/dummy/app/models/ability.rb
templus_models-3.0.8 test/dummy/app/models/ability.rb
templus_models-2.0.2 test/dummy/app/models/ability.rb
templus_models-3.0.7 test/dummy/app/models/ability.rb
templus_models-3.0.6 test/dummy/app/models/ability.rb
templus_models-3.0.5 test/dummy/app/models/ability.rb
templus_models-2.0.1 test/dummy/app/models/ability.rb
templus_models-3.0.4 test/dummy/app/models/ability.rb
templus_models-2.0.0 test/dummy/app/models/ability.rb
templus_models-1.6.5 test/dummy/app/models/ability.rb
templus_models-1.6.4 test/dummy/app/models/ability.rb
templus_models-1.6.3 test/dummy/app/models/ability.rb
templus_models-1.6.2 test/dummy/app/models/ability.rb
templus_models-1.6.0 test/dummy/app/models/ability.rb
templus_models-1.5.15 test/dummy/app/models/ability.rb
templus_models-1.5.14 test/dummy/app/models/ability.rb