Sha256: f992594272b87e9d6efa857ee149cfe550eb50152152e8eb70f2e4fbf0902385
Contents?: true
Size: 659 Bytes
Versions: 13
Compression:
Stored size: 659 Bytes
Contents
module RocketJobMissionControl class Authorization ROLES = %i[admin editor operator manager dirmon user view].freeze attr_accessor *ROLES attr_accessor :login def initialize(roles: [], login: nil) @login = login return if roles.blank? invalid_roles = roles - ROLES raise(ArgumentError, "Invalid Roles Supplied: #{invalid_roles.inspect}") unless invalid_roles.empty? roles.each { |r| inherit_less_privilege_roles(r) } end def inherit_less_privilege_roles(role) index = ROLES.index(role) roles = ROLES[index..-1] roles.each { |role| public_send("#{role}=", true) } end end end
Version data entries
13 entries across 13 versions & 1 rubygems