Class: Bizside::Acl::AccessControlUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/bizside/acl/access_control_utils.rb

Overview

アクセス制御のユーティリティクラス

Constant Summary collapse

@@access_control =
nil

Class Method Summary collapse

Class Method Details

.get_access_control(roll_key) ⇒ Object



32
33
34
# File 'lib/bizside/acl/access_control_utils.rb', line 32

def self.get_access_control(roll_key)
  @@access_control[roll_key]
end

.init(reload = false) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/bizside/acl/access_control_utils.rb', line 6

def self.init(reload = false)
  if reload or @@access_control.nil?
    @@access_control = {}
    config_files = Bizside.config.acl.config_files? ? Bizside.config.acl.config_files : ['config/acl.yml']
    config_files.each do |config|
      merge(config)
    end
  end
end

.merge(filename) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bizside/acl/access_control_utils.rb', line 16

def self.merge(filename)
  yml = YAML.load_file(filename)
  
  yml.each do |roll_key, values|
    @@access_control[roll_key] ||= {}
    @@access_control[roll_key].merge!(values)
  end
end

.role_keysObject



25
26
27
28
29
30
# File 'lib/bizside/acl/access_control_utils.rb', line 25

def self.role_keys
  # Railsを使用 かつ 開発環境の場合はリロードする
  init(Bizside.rails_env&.development?)

  @@access_control.keys.sort
end