Class: PermissionSettings::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/permission_settings/configuration.rb

Defined Under Namespace

Classes: PermissionsDirNotFound

Constant Summary collapse

DEFAULT_PERMISSION_FILE_PATH =
'config/permissions'
DEFAULT_ROLE_ACCESS_METHOD =
:role

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



14
15
16
17
# File 'lib/permission_settings/configuration.rb', line 14

def initialize
  @permissions_dir_path = DEFAULT_PERMISSION_FILE_PATH
  @role_access_method = DEFAULT_ROLE_ACCESS_METHOD
end

Instance Attribute Details

#permissions_dir_pathObject

Returns the value of attribute permissions_dir_path.



12
13
14
# File 'lib/permission_settings/configuration.rb', line 12

def permissions_dir_path
  @permissions_dir_path
end

#role_access_methodObject

Returns the value of attribute role_access_method.



12
13
14
# File 'lib/permission_settings/configuration.rb', line 12

def role_access_method
  @role_access_method
end

Instance Method Details

#load_permissions_file(klass) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/permission_settings/configuration.rb', line 23

def load_permissions_file(klass)
  if RUBY_VERSION.to_f >= 3.1
    YAML.load_file(permission_file_path(klass), aliases: true)
  else
    YAML.load_file(permission_file_path(klass))
  end
end

#permission_file_path(klass) ⇒ Object



31
32
33
# File 'lib/permission_settings/configuration.rb', line 31

def permission_file_path(klass)
  File.join(permissions_dir_path, "#{klass.name.underscore}.yml")
end

#scope_name(klass) ⇒ Object



19
20
21
# File 'lib/permission_settings/configuration.rb', line 19

def scope_name(klass)
  [klass.name.underscore, 'permissions'].join('_').to_sym
end