Sha256: 805a5b26747fdd679e0fa31952b2c66e3be67d0961c9e357e92aa4a9fa7a8a3e

Contents?: true

Size: 386 Bytes

Versions: 1

Compression:

Stored size: 386 Bytes

Contents

module Permisi
  class Backend::ActiveRecord::Actor < ::ActiveRecord::Base
    belongs_to :aka, polymorphic: true
    has_many :actor_roles
    has_many :roles, through: :actor_roles

    def has_role?(role_slug)
      roles.load.any? { |role| role.slug == role_slug.to_s }
    end

    def may?(action_path)
      roles.load.any? { |role| role.allows?(action_path) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
permisi-0.1.0 lib/permisi/backend/active_record/actor.rb