Module: Operations::Config

Defined in:
lib/operations/config.rb

Constant Summary collapse

@@user_roles =
[
  {name: :admin, description: 'Administrator', value: 0, db_value: 0},
  {name: :guest, description: 'Anyone', value: 3, db_value: 1},
  {name: :regular, description: 'Regular user', value: 2, db_value: 2},
  {name: :technician, description: 'Technician', value: 1, db_value: 3},
  {name: :all, description: 'Anyone on the system', value: -1},
  {name: :nobody, description: 'No one on the system', value: -2}
]
@@operation_name_regex =
%r{\w}
@@operation_uuid_algorithm =
OpenSSL::Digest::SHA256
@@operations_list =
[]
@@enforcements =
[]
@@sign_in_path =
nil

Class Method Summary collapse

Class Method Details

.get_operations_listObject



57
58
59
60
61
62
# File 'lib/operations/config.rb', line 57

def self.get_operations_list
  operations_list
      .map{|operation|
        Operations::Operation.new(**operation)}
      .select{|operation| operation.is_valid?}
end

.get_sign_in_pathObject



41
42
43
44
45
46
47
48
49
# File 'lib/operations/config.rb', line 41

def 
  if .nil?
    warn "Warning! You have not set the Operations::Config.sign_in_path variable!"
    return nil
  end
  Rails.application.routes.recognize_path 
rescue ActionController::RoutingError
  {controller: nil, action: nil}
end

.operation_scope_regexObject



33
34
35
# File 'lib/operations/config.rb', line 33

def operation_scope_regex
  %r{\A(#{user_roles.map{|o| o[:name]}.join('|')})\z}
end

.operation_scope_regex=(*args) ⇒ Object



37
38
39
# File 'lib/operations/config.rb', line 37

def operation_scope_regex=(*args)
  raise 'Operations::Config does not allow to set the variable operation_name_regex'
end

.setup {|_self| ... } ⇒ Object

A simple way to setup Operations.

Yields:

  • (_self)

Yield Parameters:



53
54
55
# File 'lib/operations/config.rb', line 53

def self.setup
  yield self
end