Class: ActiveFlags::Handler::FlagMappers::Authorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_flags/handler/flag_mappers/authorizer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorized_flags = {}, flags) ⇒ Authorizer

Returns a new instance of Authorizer.



5
6
7
8
# File 'lib/active_flags/handler/flag_mappers/authorizer.rb', line 5

def initialize(authorized_flags = {}, flags)
  @authorized_flags = authorized_flags
  @flags = flags
end

Class Method Details

.authorize(authorized_flags, flags) ⇒ Object



17
18
19
# File 'lib/active_flags/handler/flag_mappers/authorizer.rb', line 17

def self.authorize(authorized_flags, flags)
  new(authorized_flags, flags).authorize
end

Instance Method Details

#authorizeObject



10
11
12
13
14
15
# File 'lib/active_flags/handler/flag_mappers/authorizer.rb', line 10

def authorize
  return @flags if @authorized_flags.empty?
  @flags.select do |flag_name, value|
    @authorized_flags.include?(flag_name)
  end
end