Module: EasyRoleRequirementSystem::ClassMethods

Defined in:
lib/easy_role_requirement_system.rb

Instance Method Summary collapse

Instance Method Details

#enforce_permissionsObject

calls RoleRequirementSystem::require_role for every permission set in the config file for the current controller



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/easy_role_requirement_system.rb', line 61

def enforce_permissions
   controller_permissions.each do |permission|         
     all_parameters = []                  
     permission.each do |p|
       check_format(p)
       parameter = {}           
       parameter[:roles]   = add_roles(p)
       parameter[:options] = (reformat_options(p[:options]) if p[:options]) || {}        
       all_parameters << parameter
     end
     all_parameters.each{|param| self.require_role(param[:roles], param[:options]) \
       if param[:roles]}
   end
end

#has_role_requirements?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/easy_role_requirement_system.rb', line 55

def has_role_requirements?
  self.role_requirements && self.role_requirements != [] ? true : false
end

#role_permissions_file_pathObject



51
52
53
# File 'lib/easy_role_requirement_system.rb', line 51

def role_permissions_file_path
  @role_permissions_file_path ||= "#{RAILS_ROOT}/config/spree_permissions.yml"
end