Sha256: 22e7526b2bdcaea9ee0fbb9e30508fcef7cac73b81bd8324b899e52cc25faf88
Contents?: true
Size: 930 Bytes
Versions: 32
Compression:
Stored size: 930 Bytes
Contents
require "set" require "virtus" module Ddr::Auth module Roles extend Deprecation # # Wraps a set of Roles # class RoleSet include Virtus.model include Enumerable include ActiveModel::Serializers::JSON attribute :roles, Set[Role] delegate :where, :agent, :scope, :role_type, :in_policy_scope, :in_resource_scope, to: :query delegate :each, :empty?, :clear, to: :roles def self.from_json(json) new.from_json(json.present? ? json : "{}") end def ==(other) instance_of?(other.class) && self.roles == other.roles end def merge(other) self.roles += other.roles self end def permissions map(&:permissions).flatten.uniq end def agents map(&:agent).uniq end def query RoleSetQuery.new(self) end end end end
Version data entries
32 entries across 32 versions & 1 rubygems