Class: Ddr::Auth::Roles::RoleSet

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON, Enumerable
Defined in:
lib/ddr/auth/roles/role_set.rb

Overview

Wraps a set of Roles

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_json(json) ⇒ Object



23
24
25
# File 'lib/ddr/auth/roles/role_set.rb', line 23

def self.from_json(json)
  new.from_json(json.present? ? json : "{}")
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/ddr/auth/roles/role_set.rb', line 27

def ==(other)
  instance_of?(other.class) && self.roles == other.roles
end

#agentsObject



40
41
42
# File 'lib/ddr/auth/roles/role_set.rb', line 40

def agents
  map(&:agent).uniq
end

#merge(other) ⇒ Object



31
32
33
34
# File 'lib/ddr/auth/roles/role_set.rb', line 31

def merge(other)
  self.roles += other.roles
  self
end

#permissionsObject



36
37
38
# File 'lib/ddr/auth/roles/role_set.rb', line 36

def permissions
  map(&:permissions).flatten.uniq
end

#queryObject



44
45
46
# File 'lib/ddr/auth/roles/role_set.rb', line 44

def query
  RoleSetQuery.new(self)
end